-
Notifications
You must be signed in to change notification settings - Fork 13
Writing tests
We strive to test all functionality in SpenDB. If you add a new functionality to the code base, please take the time to create a test for it. We regression test everything that is contributed into the code base.
If tests need to be removed or modified as part of a code contributions, please indicate so clearly in the relevant commit, preferably using ALL CAPS in the first line of the commit message.
All tests can be found in spendb.tests
, arranged into directories by
what part of spendb they test:
-
command
: Tests forostool
functionality (code inspendb.command
) -
views
: Tests for user facing functionality (access points via URLs) as SpenDB follows an MVC (model, view, controller) architecture (code inspendb.views
with templates intemplates
). -
importer
: Tests for the CSV importer in SpenDB, the important bit handled byCelery
to get data into SpenDB (code inspendb.importer
which is called fromspendb.tasks
which callsspendb.command
). -
lib
: Tests generic spendb functions and classes made designed to be reusable all over the code base. These include solr wrappers, parameter parsers and views (code inspendb.lib
). -
model
: Tests for the database model functionality (the database interface) as SpenDB follows an MVC architecture (code inspendb.model
).
Test cases should inherit from the Test classed made available in
spendb.tests.base
:
-
TestCase
: Tests for functionality without touching the database -
DatabaseTestCase
: Tests that need to test database interactions -
ControllerTestCase
: Tests that need to test HTTP interactions
In spendb.tests.helpers
a few functions are made available that can
make tests easier to write. Noteworthy functions are make_account
to make
a user account to test with, load_fixture
to load a test dataset into the
test database, clean_and_reindex_solr
to ensure any solr tests are clean
and isolated. There are other test helper functions in
spendb.tests.helpers
and test case writers are encouraged to take a
look at the test helpers file.
Test datasets are available in the fixtures directory, both models and data.
These are loaded in via the load_fixture
function in
spendb.tests.helpers
.
Run the SpenDB test suite by running
nosetests
in the root of the repository, while in an active virtualenv.
If you are stuck with the installation or usage of SpenDB, please: search for existing bug reports or file an issue, or message the spendb mailing list.