summaryrefslogtreecommitdiff
path: root/tests/migrations/test_loader.py
diff options
context:
space:
mode:
authorJim Nicholls <jim.nicholls@sydney.edu.au>2016-08-13 19:33:58 +1000
committerTim Graham <timograham@gmail.com>2016-08-18 08:45:41 -0400
commit16f032e69fb9c06fd0d9feda35bba12195651214 (patch)
treebc3ede3aa8de5d27677c72af581afcb225402ce6 /tests/migrations/test_loader.py
parentc24a47b3e6cfba88ee7792be25da5b5333266abe (diff)
[1.10.x] Fixed #27054 -- Fixed makemigrations crash with a read-only database.
Backport of 76ab8851181675a59425f9637bdbf3f2de95f6f1 from master
Diffstat (limited to 'tests/migrations/test_loader.py')
-rw-r--r--tests/migrations/test_loader.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index c97cddb913..b46f35f7ed 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -4,11 +4,12 @@ from unittest import skipIf
from django.db import connection, connections
from django.db.migrations.exceptions import (
- AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError,
+ AmbiguityError, InconsistentMigrationHistory, MigrationSchemaMissing,
+ NodeNotFoundError,
)
from django.db.migrations.loader import MigrationLoader
from django.db.migrations.recorder import MigrationRecorder
-from django.test import TestCase, modify_settings, override_settings
+from django.test import TestCase, mock, modify_settings, override_settings
from django.utils import six
@@ -464,3 +465,12 @@ class LoaderTests(TestCase):
('app1', '4_auto'),
}
self.assertEqual(plan, expected_plan)
+
+ def test_readonly_database(self):
+ """
+ check_consistent_history() ignores read-only databases, possibly
+ without a django_migrations table.
+ """
+ with mock.patch.object(MigrationRecorder, 'ensure_schema', side_effect=MigrationSchemaMissing()):
+ loader = MigrationLoader(connection=None)
+ loader.check_consistent_history(connection)