diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2013-05-10 16:00:55 +0100 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2013-05-10 16:00:55 +0100 |
| commit | 9ce83546720b9536c02817e802c9376eb74f811d (patch) | |
| tree | 825638a0db9afbf810ffdb5312cb64e96e698553 /tests | |
| parent | cb4b0de49e027f09f8abe63e2fa43f60fc1ef13f (diff) | |
First phase of loading migrations from disk
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/migrations/0001_initial.py | 5 | ||||
| -rw-r--r-- | tests/migrations/migrations/0002_second.py | 6 | ||||
| -rw-r--r-- | tests/migrations/migrations/__init__.py | 0 | ||||
| -rw-r--r-- | tests/migrations/tests.py | 29 |
4 files changed, 35 insertions, 5 deletions
diff --git a/tests/migrations/migrations/0001_initial.py b/tests/migrations/migrations/0001_initial.py new file mode 100644 index 0000000000..bd613aa95e --- /dev/null +++ b/tests/migrations/migrations/0001_initial.py @@ -0,0 +1,5 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + pass diff --git a/tests/migrations/migrations/0002_second.py b/tests/migrations/migrations/0002_second.py new file mode 100644 index 0000000000..f4d3ba9902 --- /dev/null +++ b/tests/migrations/migrations/0002_second.py @@ -0,0 +1,6 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [("migrations", "0001_initial")] diff --git a/tests/migrations/migrations/__init__.py b/tests/migrations/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/migrations/migrations/__init__.py diff --git a/tests/migrations/tests.py b/tests/migrations/tests.py index a330330c17..56f4c9fdb9 100644 --- a/tests/migrations/tests.py +++ b/tests/migrations/tests.py @@ -1,5 +1,7 @@ from django.test import TransactionTestCase -from django.db.migrations.graph import MigrationsGraph, CircularDependencyException +from django.db import connection +from django.db.migrations.graph import MigrationGraph, CircularDependencyError +from django.db.migrations.loader import MigrationLoader class GraphTests(TransactionTestCase): @@ -16,7 +18,7 @@ class GraphTests(TransactionTestCase): app_b: 0001 <-- 0002 <-/ """ # Build graph - graph = MigrationsGraph() + graph = MigrationGraph() graph.add_dependency(("app_a", "0004"), ("app_a", "0003")) graph.add_dependency(("app_a", "0003"), ("app_a", "0002")) graph.add_dependency(("app_a", "0002"), ("app_a", "0001")) @@ -54,7 +56,7 @@ class GraphTests(TransactionTestCase): app_c: \ 0001 <-- 0002 <- """ # Build graph - graph = MigrationsGraph() + graph = MigrationGraph() graph.add_dependency(("app_a", "0004"), ("app_a", "0003")) graph.add_dependency(("app_a", "0003"), ("app_a", "0002")) graph.add_dependency(("app_a", "0002"), ("app_a", "0001")) @@ -85,7 +87,7 @@ class GraphTests(TransactionTestCase): Tests a circular dependency graph. """ # Build graph - graph = MigrationsGraph() + graph = MigrationGraph() graph.add_dependency(("app_a", "0003"), ("app_a", "0002")) graph.add_dependency(("app_a", "0002"), ("app_a", "0001")) graph.add_dependency(("app_a", "0001"), ("app_b", "0002")) @@ -93,6 +95,23 @@ class GraphTests(TransactionTestCase): graph.add_dependency(("app_b", "0001"), ("app_a", "0003")) # Test whole graph self.assertRaises( - CircularDependencyException, + CircularDependencyError, graph.forwards_plan, ("app_a", "0003"), ) + + +class LoaderTests(TransactionTestCase): + """ + Tests the disk and database loader. + """ + + def test_load(self): + """ + Makes sure the loader can load the migrations for the test apps. + """ + migration_loader = MigrationLoader(connection) + graph = migration_loader.build_graph() + self.assertEqual( + graph.forwards_plan(("migrations", "0002_second")), + [("migrations", "0001_initial"), ("migrations", "0002_second")], + ) |
