| | 1788 | |
| | 1789 | class ManagementCommandsTest(TestCase): |
| | 1790 | multi_db = True |
| | 1791 | |
| | 1792 | def test01flush(self): |
| | 1793 | from django.core.management import call_command |
| | 1794 | from django.contrib.contenttypes.models import ContentType |
| | 1795 | ContentType.objects.all().delete() |
| | 1796 | ContentType.objects.using('other').all().delete() |
| | 1797 | call_command('flush', database='other', interactive=False) |
| | 1798 | self.assertTrue(ContentType.objects.using('other').all()) |
| | 1799 | call_command('flush', database='default', interactive=False) |
| | 1800 | self.assertTrue(ContentType.objects.using('default').all()) |
| | 1801 | |
| | 1802 | def test02permissions(self): |
| | 1803 | from django.core.management import call_command |
| | 1804 | from django.contrib.auth.models import Permission |
| | 1805 | from django.contrib.contenttypes.models import ContentType |
| | 1806 | ContentType.objects.all().delete() |
| | 1807 | ContentType.objects.using('other').all().delete() |
| | 1808 | call_command('flush', database='other', interactive=False) |
| | 1809 | self.assertTrue(Permission.objects.using('other').all()) |
| | 1810 | |
| | 1811 | def test03createsuperuser(self): |
| | 1812 | from django.core.management import call_command |
| | 1813 | from django.contrib.auth.models import User |
| | 1814 | call_command('createsuperuser', database='other', |
| | 1815 | username='admin', email='admin@example.com', |
| | 1816 | interactive=False) |
| | 1817 | self.assertTrue(User.objects.using('other').all()) |