summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-11 14:01:02 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-11 17:30:46 +0100
commitd68eed24e409cf6b5c15c77fbf1034843eea9acd (patch)
tree53a7b08c771d8b454fe83b4b7fc40f7ca5b62277 /archaeological_finds/tests.py
parentf0f17e614d03140fef0b1dff3aca8fdb9e06aded (diff)
downloadIshtar-d68eed24e409cf6b5c15c77fbf1034843eea9acd.tar.bz2
Ishtar-d68eed24e409cf6b5c15c77fbf1034843eea9acd.zip
Fix history M2M save
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index cefeb1649..231ac30ad 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -861,15 +861,19 @@ class FindHistoryTest(FindInit, TestCase):
def test_m2m_history_save(self):
find = self.finds[0]
user = self.get_default_user()
- nb_hist = find.history.count()
ceram = models.MaterialType.objects.get(txt_idx='ceramic').pk
glass = models.MaterialType.objects.get(txt_idx='glass').pk
+
+ find = models.Find.objects.get(pk=find.pk)
+ nb_hist = find.history.count()
+ find.label = "hop hop hop1"
+ find.history_modifier = user
+ find._force_history = True
+ find.save()
find.material_types.add(ceram)
find.material_types.add(glass)
d1_txt, d2_txt = self._add_datings(find)
-
- find = models.Find.objects.get(pk=find.pk)
self.assertIn(
find.historical_material_types,
[HISTORY_M2M_SPLIT.join(['ceramic', 'glass']), # order do not
@@ -880,20 +884,16 @@ class FindHistoryTest(FindInit, TestCase):
HISTORY_M2M_SPLIT.join([d2_txt, d1_txt])]) # matter
historical_material_types = find.historical_material_types
- find.label = "hop hop hop1"
- find.history_modifier = user
- find._force_history = True
- find.save()
find = models.Find.objects.get(pk=find.pk)
- find.material_types.remove(ceram)
- find.datings.clear()
find.label = "hop hop hop2"
find.history_modifier = user
if hasattr(find, 'skip_history_when_saving'):
delattr(find, 'skip_history_when_saving')
find._force_history = True
find.save()
+ find.material_types.remove(ceram)
+ find.datings.clear()
find = models.Find.objects.get(pk=find.pk)
self.assertEqual(find.historical_material_types, 'glass')
@@ -908,33 +908,33 @@ class FindHistoryTest(FindInit, TestCase):
c = Client()
user = self.get_default_user()
find = self.finds[0]
-
- find = models.Find.objects.get(pk=find.pk)
ceram = models.MaterialType.objects.get(txt_idx='ceramic').pk
glass = models.MaterialType.objects.get(txt_idx='glass').pk
- find.material_types.add(ceram)
- find.material_types.add(glass)
- self._add_datings(find)
+
+ find = models.Find.objects.get(pk=find.pk)
find.history_modifier = user
find.label = "hop hop hop1"
find._force_history = True
if hasattr(find, 'skip_history_when_saving'):
delattr(find, 'skip_history_when_saving')
find.save()
+ find.material_types.add(ceram)
+ find.material_types.add(glass)
+ self._add_datings(find)
find = models.Find.objects.get(pk=find.pk)
- find.material_types.remove(ceram)
find.history_modifier = user
find.label = "hop hop hop2"
- find.datings.clear()
find._force_history = True
if hasattr(find, 'skip_history_when_saving'):
delattr(find, 'skip_history_when_saving')
find.save()
+ find.datings.clear()
+ find.material_types.remove(ceram)
find = models.Find.objects.get(pk=find.pk)
- history_date = find.history.all()[1].history_date.strftime(
- '%Y-%m-%dT%H:%M:%S.%f')
+ history_date = find.history.order_by('-history_date').all()[
+ 1].history_date.strftime('%Y-%m-%dT%H:%M:%S.%f')
c.login(username=self.username, password=self.password)
response = c.get(reverse('show-find',
@@ -957,7 +957,8 @@ class FindHistoryTest(FindInit, TestCase):
content = response.content.decode('utf-8')
self.assertIn(
models.MaterialType.objects.get(txt_idx='ceramic').label, content)
- self.assertIn("5001", content)
+ self.assertIn("5001", content, msg=u"5001 not found in historical "
+ u"sheet")
self.assertIn(
Period.objects.get(txt_idx='neolithic').label, content)