Skip to content
Ling-Xiao Yang edited this page Jan 8, 2016 · 2 revisions

Test data is generated by model_mommy, instead of provided by Django fixtures. model_mommy automatically creates all required foreign key relationships and populates them with arbitrary data, and thus the test data can focus on the most important aspects of the model and is not subject to any changes in Rodan model.

A test case should inherit RodanTestSetUpMixin and RodanTestTearDownMixin together with REST Framework's APITestCase. RodanTestSetUpMixin provides several methods named setUp_xxx() to create objects using model_mommy and attach them to self. RodanTestTearDownMixin deletes the temporary folder used during test. It should be noted that the Project and Resource folders during test are not the same with production folder -- during the test the media folder is set to a temporary folder and RodanTestTearDownMixin cleans the temporary filesystem. Therefore, the sequence of the base classes is important:

class MyRodanTestCase(RodanTestTearDownMixin, APITestCase, RodanTestSetUpMixin)

RodanTestTearDownMixin must be put as the first of the list to mask the empty tearDown method of APITestCase.

The tests on views use superuser to perform to avoid being connected with permission system. The permission test is provided as separate test classes.

Clone this wiki locally