summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-24 19:34:27 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-24 19:37:02 +0200
commit73eedc117776ad42e2241232ad1dcc547cb967b2 (patch)
treefb1c2133c08e1bdc3d1a087618c59776546ee266 /archaeological_context_records/tests.py
parent8fa0f928e68e10d4ef055bf9afd47e0e91ce7b55 (diff)
downloadIshtar-73eedc117776ad42e2241232ad1dcc547cb967b2.tar.bz2
Ishtar-73eedc117776ad42e2241232ad1dcc547cb967b2.zip
Datings: post-fix of duplicates associated to the same object (usually on imports)
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r--archaeological_context_records/tests.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index b613b837e..b64754ad6 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -352,6 +352,21 @@ class ContextRecordTest(ContextRecordInit, TestCase):
self.assertEqual(response.status_code, 200)
self.assertIn('class="sheet"', response.content)
+ def test_redundant_dating_clean(self):
+ obj = self.context_records[0]
+ values = {'period': models.Period.objects.all()[0]}
+ values_2 = {'period': models.Period.objects.all()[0],
+ 'quality': models.DatingQuality.objects.all()[0]}
+
+ obj.datings.add(models.Dating.objects.create(**values))
+ obj.datings.add(models.Dating.objects.create(**values))
+ obj.datings.add(models.Dating.objects.create(**values_2))
+ obj.datings.add(models.Dating.objects.create(**values_2))
+ self.assertEqual(obj.datings.count(), 4)
+ obj.fix()
+ self.assertEqual(obj.datings.count(), 2)
+
+
class ContextRecordSearchTest(ContextRecordInit, TestCase):
fixtures = ImportContextRecordTest.fixtures
@@ -558,22 +573,23 @@ class ContextRecordWizardCreationTest(WizardTest, ContextRecordInit, TestCase):
'general': {
'label': "First"
},
- 'relations': []
+ 'relations': [],
},
ignored=('datings',
'interpretation',
)
),
FormData(
- "Create a context record with a relation",
+ "Create a context record with a relation and datings",
form_datas={
'selec': {},
'general': {
'label': "Second"
},
- 'relations': []
+ 'relations': [],
+ 'datings': []
},
- ignored=('datings', 'interpretation',)
+ ignored=('interpretation',)
),
]
@@ -598,6 +614,14 @@ class ContextRecordWizardCreationTest(WizardTest, ContextRecordInit, TestCase):
label="Test").pk}
)
+ period = models.Period.objects.all()[0].pk
+ self.form_datas[1].append(
+ 'datings', {'period': period}
+ )
+ self.form_datas[1].append(
+ 'datings', {'period': period}
+ )
+
self.cr_nb = models.ContextRecord.objects.count()
super(ContextRecordWizardCreationTest, self).pre_wizard()
@@ -606,3 +630,6 @@ class ContextRecordWizardCreationTest(WizardTest, ContextRecordInit, TestCase):
self.cr_nb + 2)
self.assertEqual(self.related_cr.left_relations.count(),
1)
+ # identical datings, only one should be finaly save
+ cr = models.ContextRecord.objects.order_by('-pk')[0]
+ self.assertEqual(cr.datings.count(), 1)