summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/models.py1
-rw-r--r--archaeological_context_records/tests.py36
2 files changed, 36 insertions, 1 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 1b81f3b63..b0e72c4a1 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -421,6 +421,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem,
pgettext_lazy("key for text search", "site"),
'cached_label'),
}
+ MAIN_UP_MODEL_QUERY = "operation"
RELATIVE_SESSION_NAMES = [
('operation', 'operation__pk'),
('site', 'archaeological_site__pk'),
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index a0a76ba78..9e16603de 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -886,6 +886,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
self.create_context_record({"label": u"CR 1B"})
self.create_context_record({"label": u"CR 2B"})
self.create_context_record({"label": u"CR 3B"})
+ self.create_context_record({"label": u"CR 2C"})
+ self.create_context_record({"label": u"CR 2D"})
cr_1 = self.context_records[0]
self.cr_2 = cr_2 = self.context_records[1]
@@ -894,6 +896,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
cr_1B = self.context_records[4]
cr_2B = self.context_records[5]
cr_3B = self.context_records[6]
+ cr_2C = self.context_records[7]
+ cr_2D = self.context_records[8]
models.RecordRelations.objects.create(
left_record=cr_2, right_record=cr_2B,
@@ -915,8 +919,14 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
models.RecordRelations.objects.create(
left_record=cr_3B, right_record=cr_2B,
relation_type=self.rel_type_above)
+ models.RecordRelations.objects.create(
+ left_record=cr_3B, right_record=cr_2C,
+ relation_type=self.rel_type_above)
+ models.RecordRelations.objects.create(
+ left_record=cr_2D, right_record=cr_3B,
+ relation_type=self.rel_type_bellow)
- def test_gen_relation_full(self):
+ def test_gen_relation(self):
generate_relation_graph(self.cr_2)
cr_2 = models.ContextRecord.objects.get(pk=self.cr_2.pk)
self.assertIsNotNone(cr_2.relation_image)
@@ -930,6 +940,26 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
self.assertIn('"CR 3"', content)
self.assertIn('"CR 3B"', content)
self.assertIn('"CR 4"', content)
+ self.assertNotIn('"CR 2C"', content)
+ self.assertNotIn('"CR 2D"', content)
+
+ def test_gen_relation_full(self):
+ generate_relation_graph(self.cr_2, full=True)
+ cr_2 = models.ContextRecord.objects.get(pk=self.cr_2.pk)
+ operation = cr_2.operation
+ self.assertIsNotNone(operation.relation_image)
+ self.assertIsNotNone(operation.relation_bitmap_image)
+ self.assertIsNotNone(operation.relation_dot)
+ content = open(operation.relation_dot.path).read()
+ self.assertIn('"CR 1"', content)
+ self.assertIn('"CR 1B"', content)
+ self.assertIn('"CR 2B"', content)
+ self.assertIn('"CR 2",style=filled,fillcolor="#C6C0C0"', content)
+ self.assertIn('"CR 3"', content)
+ self.assertIn('"CR 3B"', content)
+ self.assertIn('"CR 4"', content)
+ self.assertIn('"CR 2C"', content)
+ self.assertIn('"CR 2D"', content)
def test_gen_relation_above(self):
generate_relation_graph(self.cr_2, render_above=False)
@@ -945,6 +975,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
self.assertNotIn('"CR 3B"', content)
self.assertNotIn('"CR 3"', content)
self.assertNotIn('"CR 4"', content)
+ self.assertNotIn('"CR 2C"', content)
+ self.assertNotIn('"CR 2D"', content)
def test_gen_relation_bellow(self):
generate_relation_graph(self.cr_2, render_bellow=False)
@@ -960,5 +992,7 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
self.assertIn('"CR 3"', content)
self.assertIn('"CR 3B"', content)
self.assertIn('"CR 4"', content)
+ self.assertNotIn('"CR 2C"', content)
+ self.assertNotIn('"CR 2D"', content)