mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Make migrate command recognise prefixes and 'zero'.
This commit is contained in:
parent
52eb19b545
commit
162f7b938f
4 changed files with 95 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.db import connection
|
||||
from django.db.migrations.loader import MigrationLoader
|
||||
from django.db.migrations.loader import MigrationLoader, AmbiguityError
|
||||
from django.db.migrations.recorder import MigrationRecorder
|
||||
|
||||
|
||||
|
@ -64,3 +64,16 @@ class LoaderTests(TestCase):
|
|||
[x for x, y in book_state.fields],
|
||||
["id", "author"]
|
||||
)
|
||||
|
||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
||||
def test_name_match(self):
|
||||
"Tests prefix name matching"
|
||||
migration_loader = MigrationLoader(connection)
|
||||
self.assertEqual(
|
||||
migration_loader.get_migration_by_prefix("migrations", "0001").name,
|
||||
"0001_initial",
|
||||
)
|
||||
with self.assertRaises(AmbiguityError):
|
||||
migration_loader.get_migration_by_prefix("migrations", "0")
|
||||
with self.assertRaises(KeyError):
|
||||
migration_loader.get_migration_by_prefix("migrations", "blarg")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue