Integrity error when loading fixtures for Selenium testing in Django -


i want load fixture selenium testing. using fixtures successful in initial tests, know capable of loading fixtures in test setup , using them in tests. have attempted several approaches. first, generated fixtures specific models testing using dumpdata. example below:

python manage.py dumpdata protocols.step --indent=2 > functional_tests/fixtures/step.json 

when used in test so:

class signintest(functionaltest):     fixtures = ['admin_user.json', 'protocol.json', 'step.json',              'protocol_element.json']      def test_login_and_view_user_data(self):         ... 

i error:

django.db.utils.integrityerror: problem installing fixtures: row in table 'protocols_protocolelement' primary key '37' has invalid foreign key: protocols_protocolelement.element_content_type_id contains value '41' not have corresponding value in django_content_type.id. 

second attempt involved using test data in tables, excluding contenttypes:

python manage.py dumpdata --indent=2 -e contenttypes > functional_tests/fixtures/initial_data.json  class signintest(functionaltest):     fixtures = ['initial_data.json']     ... 

getting error:

django.db.utils.operationalerror: problem installing fixture '.../mike/mike/functional_tests/fixtures/initial_data.json': not load auth.permission(pk=103): no such table: auth_permission 

next, tried using natural show natural keys:

python manage.py dumpdata --natural -e contenttypes -e auth.permission --indent=2 > functional_tests/fixtures/initial_data2.json 

only error:

django.db.utils.operationalerror: problem installing fixture '.../mike/mike/functional_tests/fixtures/initial_data.json': not load auth.user(pk=1): no such table: auth_user 

noticing natural depreciated tried --natural-foreign , wanted include user , permission models (i need contenttypes models anyway):

python manage.py dumpdata --natural-foreign --indent=2 > functional_tests/fixtures/initial_data3.json 

only error:

django.db.utils.integrityerror: problem installing fixture '.../mike/mike/functional_tests/fixtures/initial_data3.json': not load contenttypes.contenttype(pk=35): unique constraint failed: django_content_type.app_label, django_content_type.model 

so, ideas on how load fixture can run tests? there simple i'm missing? thanks!

after more reading how django maintains own models , such, understanding django caches contenttype, auth.permission, etc , uses them in testing frameworks (i using staticliveservertestcase). means when loading fixture, clashing data django had stored own uses causing integrity error. worked me:

python manage.py dumpdata -e contenttypes -e admin -e auth.permission --natural-foreign --indent=2 > functional_tests/fixtures/initial_data4.json 

this post has additional helpful information me solve problem: problems contenttypes when loading fixture in django.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -