summaryrefslogtreecommitdiff
path: root/tests/migrations/test_commands.py
diff options
context:
space:
mode:
authorwtkm11 <wtkm11@users.noreply.github.com>2020-04-25 14:54:20 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-19 10:24:23 +0200
commit9756c334294ad573d887b449e2fe1cc87387af40 (patch)
tree8fe6be895167a4eb208fa65bfaf92b414288ed33 /tests/migrations/test_commands.py
parent952afc166c8d79013b7181e35aab638145d2adc5 (diff)
Fixed #31504 -- Allowed calling makemigrations without an active database connection.
Diffstat (limited to 'tests/migrations/test_commands.py')
-rw-r--r--tests/migrations/test_commands.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index a0b33ca6f5..69fdf28747 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -8,7 +8,8 @@ from unittest import mock
from django.apps import apps
from django.core.management import CommandError, call_command
from django.db import (
- ConnectionHandler, DatabaseError, connection, connections, models,
+ ConnectionHandler, DatabaseError, OperationalError, connection,
+ connections, models,
)
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.utils import truncate_name
@@ -1555,6 +1556,19 @@ class MakeMigrationsTests(MigrationTestBase):
with self.assertRaisesMessage(InconsistentMigrationHistory, msg):
call_command("makemigrations")
+ def test_makemigrations_inconsistent_history_db_failure(self):
+ msg = (
+ "Got an error checking a consistent migration history performed "
+ "for database connection 'default': could not connect to server"
+ )
+ with mock.patch(
+ 'django.db.migrations.loader.MigrationLoader.check_consistent_history',
+ side_effect=OperationalError('could not connect to server'),
+ ):
+ with self.temporary_migration_module():
+ with self.assertWarnsMessage(RuntimeWarning, msg):
+ call_command('makemigrations', verbosity=0)
+
@mock.patch('builtins.input', return_value='1')
@mock.patch('django.db.migrations.questioner.sys.stdin', mock.MagicMock(encoding=sys.getdefaultencoding()))
def test_makemigrations_auto_now_add_interactive(self, *args):