summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-30 18:24:06 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-30 18:24:06 +0100
commit99e7697ea68dfd1829d8f3f22a8887a3346fa1bc (patch)
tree3e293a5f9d0a2213c20930465c93224abcef6a56 /ishtar_common/tests.py
parent2623764591c43c79b48e08b5e13ab3c01a9a83a0 (diff)
downloadIshtar-99e7697ea68dfd1829d8f3f22a8887a3346fa1bc.tar.bz2
Ishtar-99e7697ea68dfd1829d8f3f22a8887a3346fa1bc.zip
update-current-item: prevent errors when session is not well initialized
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 9ced28ea6..9e5fc3466 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -355,7 +355,7 @@ class ShortMenuTest(TestCase):
if not user:
user = self.other_user
from archaeological_operations.models import Operation, OperationType
- ope_type = OperationType.objects.create()
+ ope_type, created = OperationType.objects.get_or_create(label="test")
return Operation.objects.create(
operation_type=ope_type,
history_modifier=user,
@@ -662,6 +662,28 @@ class ShortMenuTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertFalse(str(treat.cached_label) in response.content)
+ def test_update_current_item(self):
+ c = Client()
+ c.login(username=self.username, password=self.password)
+ base_find, find = self._create_find()
+
+ response = c.get(reverse('pin', args=['find', find.pk]))
+ self.assertEqual(response.status_code, 200)
+ # the selected find is pined
+ self.assertEqual(c.session['find'], str(find.pk))
+ # dependant items are also pined
+ self.assertEqual(c.session['contextrecord'],
+ str(base_find.context_record.pk))
+ self.assertEqual(c.session['operation'],
+ str(base_find.context_record.operation.pk))
+
+ # pin another operation - dependant items are nullify
+ ope = self._create_ope()
+ response = c.get(reverse('pin', args=['operation', ope.pk]))
+ self.assertEqual(response.status_code, 200)
+ self.assertFalse(c.session['find'])
+ self.assertFalse(c.session['contextrecord'])
+
class ImportTest(TestCase):
def testDeleteRelated(self):