To get started and make sure this all works, please make sure you have Python nose installed.
nosetests rethinkORM -v -s
This will run the all the tests, not capturing stdout and being verbose, in case anything goes wrong, or if you modify the tests. Please note, tests are subject to a lot of changes, and this may not always be the same command.
If you want to also check the PEP8 validity of the code, you can run:
pep8 rethinkORM
or, if you have tissue installed you can run a PEP8 check with the rest of the test suite like so:
nosetests rethinkORM -v -s --with-tissue
There is a setup fixture that creates a database called model and within that creates a table stargate. Then each test works on entries which get stored in this database and table. When everything is done, the teardown fixture is ran to clean up and delete the whole database model. Each test should be broken down into basic actions, for example there are currently tests for:
- inserting a new entry
- modifying that entry
- deleting that entry
- inserting an entry where the primary key is None or a null value.
Test suite for the model
Bases: object
Base test object to help automate some of the repetitive work of reloading a document to ensure the model matches the test data. Also takes care of deleting the document if cleanupAfter is True
Should the document created by this test be deleted when over?
Should the document be reloaded and have all it’s data checked against?
If loadCheck is true, fill this out with strings of the data keys to check the model against.
The model being used for this test
The data being used for this test. Please at least include an ID
Override this to do a custom load check. This should find the key you created or modified in action() and check it’s values to ensure everything was set correctly. By default this loads the model with the test objects data[“id”] and uses whatToLoad to run checks against the data and the model.
Bases: rethinkORM.tests.test_model.base
Tests the basic ability to make a new model instance, and save it to the Database
alias of gateModel
Bases: rethinkORM.tests.test_model.base
Tests the ability to load, modify and save a model correctly
alias of gateModel
Here we test to make sure that if we give a primary key of type None that we are raising an exception, if we don’t get an exception then something is wrong since the primary key shouldn’t be allowed to be None
Make sure that the model raises an Exception when a key and data are provided
Bases: rethinkORM.tests.test_model.base
Tests the new() classmethod of the model
alias of gateModel
Bases: rethinkORM.tests.test_model.base
Tests the create() classmethod of the model
Same as the new() classmethod test however we don’t have to explicitly tell the model to save
alias of gateModel
Bases: rethinkORM.tests.test_model.base
Tests the find() classmethod of the model
alias of gateModel