summaryrefslogtreecommitdiff
path: root/tests/user_commands
diff options
context:
space:
mode:
authorMounir Messelmeni <messelmeni.mounir@gmail.com>2016-02-12 11:02:36 +0100
committerTim Graham <timograham@gmail.com>2016-02-12 13:34:56 -0500
commit50931dfa5310d5ae1c6e2852d05bf1e86700827f (patch)
tree18350e95bf9dce60b35da528a898525b9155044e /tests/user_commands
parent004ba0f99eb25c3f32aa3a41707534e955d1878e (diff)
Fixed #25304 -- Allowed management commands to check if migrations are applied.
Diffstat (limited to 'tests/user_commands')
-rw-r--r--tests/user_commands/tests.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 2c19339ddc..9ce1399040 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -7,12 +7,14 @@ from django.core import management
from django.core.management import BaseCommand, CommandError, find_commands
from django.core.management.utils import find_command, popen_wrapper
from django.db import connection
-from django.test import SimpleTestCase, override_settings
+from django.test import SimpleTestCase, mock, override_settings
from django.test.utils import captured_stderr, extend_sys_path
from django.utils import translation
from django.utils._os import upath
from django.utils.six import StringIO
+from .management.commands import dance
+
# A minimal set of apps to avoid system checks running on all apps.
@override_settings(
@@ -161,6 +163,18 @@ class CommandTests(SimpleTestCase):
finally:
BaseCommand.check = saved_check
+ def test_check_migrations(self):
+ requires_migrations_checks = dance.Command.requires_migrations_checks
+ try:
+ with mock.patch.object(BaseCommand, 'check_migrations') as check_migrations:
+ management.call_command('dance', verbosity=0)
+ self.assertFalse(check_migrations.called)
+ dance.Command.requires_migrations_checks = True
+ management.call_command('dance', verbosity=0)
+ self.assertTrue(check_migrations.called)
+ finally:
+ dance.Command.requires_migrations_checks = requires_migrations_checks
+
class CommandRunTests(AdminScriptTestCase):
"""