bigchaindb/tests
vrde 6f5c55c044 Fail if config file not found 2017-06-29 11:06:49 +02:00
..
assets remove structural and schematic validations from Transaction.validate which is validating the spend 2017-03-14 12:39:57 +01:00
backend Merge branch 'feat/1281/mongodb-ssl-auth' of https://github.com/tomconte/bigchaindb into tomconte-feat/1281/mongodb-ssl-auth 2017-03-28 15:16:16 +02:00
commands Fail if config file not found 2017-06-29 11:06:49 +02:00
common fixed pep8 error 2017-03-16 14:18:57 +01:00
db No duplicate vote inserts with mongodb (#1258) 2017-03-22 14:25:16 +01:00
integration dedupe tx in block, reject duplicate tx in block 2017-03-02 14:35:20 +01:00
log Set error log file according to user given setting 2017-04-18 16:21:02 +02:00
pipelines Fix typos 2017-04-12 14:39:15 +02:00
web Merge branch 'remove-useless-capped-queue' 2017-04-18 16:38:26 +02:00
README.md Use MongoDB as default db in docker-compose file 2017-04-18 16:14:21 +02:00
__init__.py Add code, have fun! 2016-02-10 19:55:33 +01:00
conftest.py Fail if config file not found 2017-06-29 11:06:49 +02:00
test_config_utils.py Fail if config file not found 2017-06-29 11:06:49 +02:00
test_consensus.py fix tests, temporarily disabling some tests that need to be re-written 2017-02-23 21:53:12 +01:00
test_core.py Add test to reproduce false double spend 2017-03-16 17:04:50 +01:00
test_docs.py add test to make sure documentation can build 2016-11-30 16:41:24 +01:00
test_events.py added tests for the events 2017-04-07 15:02:49 +02:00
test_models.py Voting pipeline now checks for duplicated transactions in blocks during 2017-04-04 17:57:44 +02:00
test_processes.py Refine test for the election pipeline process 2017-04-11 17:24:21 +02:00
test_txlist.py fix flake8 2017-01-18 17:13:38 +01:00
test_utils.py Simplify run function 2017-01-26 17:12:35 +01:00
test_voting.py use patch instead of subclassing 2017-04-13 11:38:17 +02:00
utils.py Resolves #948 2017-01-16 07:12:25 -05:00

README.md

BigchainDB Server Tests

The tests/ Folder

The tests/ folder is where all the tests for BigchainDB Server live. Most of them are unit tests. Integration tests are in the tests/integration/ folder.

A few notes:

Writing Tests

We write unit and integration tests for our Python code using the pytest framework. You can use the tests in the tests/ folder as templates or examples.

Running Tests

Running Tests Directly

If you installed BigchainDB Server using pip install bigchaindb, then you didn't install the tests. Before you can run all the tests, you must install BigchainDB from source. The CONTRIBUTING.md file has instructions for how to do that.

Next, make sure you have RethinkDB or MongoDB running in the background. You can run RethinkDB using rethinkdb --daemon or MongoDB using mongod --replSet=rs0.

The pytest command has many options. If you want to learn about all the things you can do with pytest, see the pytest documentation. We've also added a customization to pytest:

--database-backend: Defines the backend to use for the tests. It defaults to rethinkdb It must be one of the backends available in the server configuration.

Now you can run all tests using:

py.test -v

or, if that doesn't work, try:

python -m pytest -v

or:

python setup.py test

Note: the above pytest commands default to use RethinkDB as the backend. If you wish to run the tests against MongoDB add the --database-backend=mongodb to the pytest command.

How does python setup.py test work? The documentation for pytest-runner explains.

The pytest command has many options. If you want to learn about all the things you can do with pytest, see the pytest documentation. We've also added a customization to pytest:

Running Tests with Docker Compose

You can also use Docker Compose to run all the tests.

With MongoDB as the backend

First, start MongoDB in the background:

$ docker-compose up -d mdb

then run the tests using:

$ docker-compose run --rm bdb py.test -v

If you've upgraded to a newer version of BigchainDB, you might have to rebuild the images before being able to run the tests. Run:

$ docker-compose build

With RethinkDB as the backend

First, start RethinkDB in the background:

$ docker-compose up -d rdb

then run the tests using:

$ docker-compose run --rm bdb-rdb py.test -v

to rebuild all the images (usually you only need to rebuild the bdb and bdb-rdb images).

Automated Testing of All Pull Requests

We use Travis CI, so that whenever someone creates a new BigchainDB pull request on GitHub, Travis CI gets the new code and does a bunch of stuff. You can find out what we tell Travis CI to do in the .travis.yml file: it tells Travis CI how to install BigchainDB, how to run all the tests, and what to do "after success" (e.g. run codecov). (We use Codecov to get a rough estimate of our test coverage.)

Tox

We use tox to run multiple suites of tests against multiple environments during automated testing. Generally you don't need to run this yourself, but it might be useful when troubleshooting a failing Travis CI build.

To run all the tox tests, use:

tox

or:

python -m tox

To run only a few environments, use the -e flag:

tox -e {ENVLIST}

where {ENVLIST} is one or more of the environments specified in the tox.ini file.