diff options
| author | Emre Yilmaz <mail@emreyilmaz.me> | 2015-12-03 18:51:39 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-12-21 12:54:29 -0500 |
| commit | 63a6a653d4282f74e35582d41ca507139c9cfbe1 (patch) | |
| tree | 51488cfd102ba5ea4858415aa60ecb6bee5eff9f /tests/admin_scripts/tests.py | |
| parent | 541000773a19d829a46fd4bec3655dca38a95551 (diff) | |
Fixed #25855 -- Enhanced the migration warning for runserver.
Added unapplied migration count and the list of unmigrated apps.
Diffstat (limited to 'tests/admin_scripts/tests.py')
| -rw-r--r-- | tests/admin_scripts/tests.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index ea7c8a25f0..805be8b144 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -26,7 +26,7 @@ from django.db import ConnectionHandler from django.db.migrations.exceptions import MigrationSchemaMissing from django.db.migrations.recorder import MigrationRecorder from django.test import ( - LiveServerTestCase, SimpleTestCase, mock, override_settings, + LiveServerTestCase, SimpleTestCase, TestCase, mock, override_settings, ) from django.test.runner import DiscoverRunner from django.utils._os import npath, upath @@ -1383,6 +1383,36 @@ class ManageRunserver(AdminScriptTestCase): self.assertIn("Not checking migrations", self.output.getvalue()) +class ManageRunserverMigrationWarning(TestCase): + + def setUp(self): + from django.core.management.commands.runserver import Command + self.stdout = StringIO() + self.runserver_command = Command(stdout=self.stdout) + + @override_settings(INSTALLED_APPS=["admin_scripts.app_waiting_migration"]) + def test_migration_warning_one_app(self): + self.runserver_command.check_migrations() + output = self.stdout.getvalue() + self.assertIn('You have 1 unapplied migration(s)', output) + self.assertIn('apply the migrations for app(s): app_waiting_migration.', output) + + @override_settings( + INSTALLED_APPS=[ + "admin_scripts.app_waiting_migration", + "admin_scripts.another_app_waiting_migration", + ], + ) + def test_migration_warning_multiple_apps(self): + self.runserver_command.check_migrations() + output = self.stdout.getvalue() + self.assertIn('You have 2 unapplied migration(s)', output) + self.assertIn( + 'apply the migrations for app(s): another_app_waiting_migration, ' + 'app_waiting_migration.', output + ) + + class ManageRunserverEmptyAllowedHosts(AdminScriptTestCase): def setUp(self): self.write_settings('settings.py', sdict={ |
