Code

Ticket #14662: multidb_management_tests.diff

File multidb_management_tests.diff, 1.8 KB (added by marcop, 3 years ago)
Line 
1Index: tests/regressiontests/multiple_database/tests.py
2===================================================================
3--- tests/regressiontests/multiple_database/tests.py    (revisione 14524)
4+++ tests/regressiontests/multiple_database/tests.py    (copia locale)
5@@ -1785,3 +1785,33 @@
6         b.authors.clear()
7         self._write_to_default()
8         self.assertEqual(receiver._database, "other")
9+
10+class ManagementCommandsTest(TestCase):
11+    multi_db = True
12+
13+    def test01flush(self):
14+        from django.core.management import call_command
15+        from django.contrib.contenttypes.models import ContentType
16+        ContentType.objects.all().delete()
17+        ContentType.objects.using('other').all().delete()
18+        call_command('flush', database='other', interactive=False)
19+        self.assertTrue(ContentType.objects.using('other').all())
20+        call_command('flush', database='default', interactive=False)
21+        self.assertTrue(ContentType.objects.using('default').all())
22+
23+    def test02permissions(self):
24+        from django.core.management import call_command
25+        from django.contrib.auth.models import Permission
26+        from django.contrib.contenttypes.models import ContentType
27+        ContentType.objects.all().delete()
28+        ContentType.objects.using('other').all().delete()
29+        call_command('flush', database='other', interactive=False)
30+        self.assertTrue(Permission.objects.using('other').all())
31+
32+    def test03createsuperuser(self):
33+        from django.core.management import call_command
34+        from django.contrib.auth.models import User
35+        call_command('createsuperuser', database='other',
36+                     username='admin', email='admin@example.com',
37+                     interactive=False)
38+        self.assertTrue(User.objects.using('other').all())