Tweak a test to avoid hitting a limit with SQLite.

Django cannot delete more than 999 objects at a time with SQLite.

Refs #16426, #16039.
This commit is contained in:
Aymeric Augustin 2012-11-23 10:02:18 +01:00
parent c13912ac7f
commit 2875b5dcab
1 changed files with 9 additions and 6 deletions

View File

@ -1912,18 +1912,21 @@ class SyncDBTestCase(TestCase):
def test_syncdb_to_other_database(self): def test_syncdb_to_other_database(self):
"""Regression test for #16039: syncdb with --database option.""" """Regression test for #16039: syncdb with --database option."""
count = ContentType.objects.count() cts = ContentType.objects.using('other').filter(app_label='multiple_database')
count = cts.count()
self.assertGreater(count, 0) self.assertGreater(count, 0)
ContentType.objects.using('other').delete() cts.delete()
management.call_command('syncdb', verbosity=0, interactive=False, management.call_command('syncdb', verbosity=0, interactive=False,
load_initial_data=False, database='other') load_initial_data=False, database='other')
self.assertEqual(cts.count(), count)
self.assertEqual(ContentType.objects.using("other").count(), count)
def test_syncdb_to_other_database_with_router(self): def test_syncdb_to_other_database_with_router(self):
"""Regression test for #16039: syncdb with --database option.""" """Regression test for #16039: syncdb with --database option."""
ContentType.objects.using('other').delete() cts = ContentType.objects.using('other').filter(app_label='multiple_database')
cts.delete()
try: try:
old_routers = router.routers old_routers = router.routers
router.routers = [SyncOnlyDefaultDatabaseRouter()] router.routers = [SyncOnlyDefaultDatabaseRouter()]
@ -1932,4 +1935,4 @@ class SyncDBTestCase(TestCase):
finally: finally:
router.routers = old_routers router.routers = old_routers
self.assertEqual(ContentType.objects.using("other").count(), 0) self.assertEqual(cts.count(), 0)