summaryrefslogtreecommitdiff
path: root/tests/migrations/test_graph.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-02-04 11:43:14 +0100
committerTim Graham <timograham@gmail.com>2017-02-04 11:29:39 -0500
commitce69a421f6122efa7d14cc33a983553dd39b844c (patch)
tree478c1217ac88e3e91c77801f2d7a8c71582b4b83 /tests/migrations/test_graph.py
parent2d899ce16bdbef1a015275237f0bfef4045fb6b2 (diff)
Added tests for various __repr__() methods.
Diffstat (limited to 'tests/migrations/test_graph.py')
-rw-r--r--tests/migrations/test_graph.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py
index d19839405a..799ee916fc 100644
--- a/tests/migrations/test_graph.py
+++ b/tests/migrations/test_graph.py
@@ -3,7 +3,9 @@ import warnings
from django.db.migrations.exceptions import (
CircularDependencyError, NodeNotFoundError,
)
-from django.db.migrations.graph import RECURSION_DEPTH_WARNING, MigrationGraph
+from django.db.migrations.graph import (
+ RECURSION_DEPTH_WARNING, DummyNode, MigrationGraph, Node,
+)
from django.test import SimpleTestCase
@@ -407,3 +409,28 @@ class GraphTests(SimpleTestCase):
self.assertEqual(str(graph), "Graph: 5 nodes, 3 edges")
self.assertEqual(repr(graph), "<MigrationGraph: nodes=5, edges=3>")
+
+
+class NodeTests(SimpleTestCase):
+ def test_node_repr(self):
+ node = Node(('app_a', '0001'))
+ self.assertEqual(repr(node), "<Node: ('app_a', '0001')>")
+
+ def test_dummynode_repr(self):
+ node = DummyNode(
+ key=('app_a', '0001'),
+ origin='app_a.0001',
+ error_message='x is missing',
+ )
+ self.assertEqual(repr(node), "<DummyNode: ('app_a', '0001')>")
+
+ def test_dummynode_promote(self):
+ dummy = DummyNode(
+ key=('app_a', '0001'),
+ origin='app_a.0002',
+ error_message="app_a.0001 (req'd by app_a.0002) is missing!",
+ )
+ dummy.promote()
+ self.assertIsInstance(dummy, Node)
+ self.assertFalse(hasattr(dummy, 'origin'))
+ self.assertFalse(hasattr(dummy, 'error_message'))