Clear ContentType table before loading fixtures
Created by: jpic
Something has changed in the last two months, when this test used to pass:
https://travis-ci.org/political-memory/political_memory/builds/108147420
Exception this patch fixes::
======================================================================
ERROR: setUpClass (representatives_positions.tests.test_functional.PositionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/test/testcases.py", line 956, in setUpClass
'database': db_name,
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 60, in handle
self.loaddata(fixture_labels)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 100, in loaddata
self.load_label(fixture_label)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 157, in load_label
obj.save(using=self.using)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/core/serializers/base.py", line 173, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 827, in _save_table
forced_update)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 877, in _do_update
return filtered._update(values) > 0
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 580, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1062, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: Problem installing fixture '/home/jpic/work/lqdn/political_memory/memopol/fixtures/one_representative.json': Could not load contenttypes.ContentType(pk=25): UNIQUE constraint failed: django_content_type.app_label, django_content_type.model