Skip to content

[DEV] Rebuilding common test fixtures

jc0n edited this page Jan 13, 2012 · 2 revisions

Generating test fixtures

The test suite requires test fixtures to seed some of the initial data in the database. There are several common test fixtures that may need to be regenerated if changes are made to the objects in pr_services/initial_setup.

The quick and easy method: ./manage.py genfixtures

The process of creating the fixtures is outlined below. If you want the output to be readable you may consider installing jsonlint to format the output.

easy_install demjson
sudo apt-get install python-demjson

Then, given any json file: jsonlint -f somefile.json

initial_setup_default.json

./manage.py resetdb
./manage.py setup
./manage.py dumpdata --natural pr_messaging \
pr_services.{ACMethodCall,ACL,Role,ACCheckMethod,User,Address,Group,Blame,\
DomainAffiliation,Domain,AuthToken,SessionUserRole} \
    > pr_services/testlib/fixtures/initial_setup_default.json

initial_setup_precor.json

./manage.py resetdb
./manage.py setup precor
./manage.py dumpdata --natural pr_messaging file_tasks \
pr_services.{ACMethodCall,ACL,Role,ACCheckMethod,User,Address,Group,Blame,\
DomainAffiliation,Domain,AuthToken,SessionUserRole} \
    > pr_services/testlib/fixtures/initial_setup_precor.json