summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_warehouse/forms.py1
-rw-r--r--archaeological_warehouse/tests.py37
2 files changed, 37 insertions, 1 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index e91d04d61..d76ce6b70 100644
--- a/archaeological_warehouse/forms.py
+++ b/archaeological_warehouse/forms.py
@@ -184,6 +184,7 @@ class ContainerForm(ManageOldType, forms.Form):
dct['container_type'] = models.ContainerType.objects.get(
pk=dct['container_type'])
dct['location'] = models.Warehouse.objects.get(pk=dct['location'])
+ dct['responsible'] = models.Warehouse.objects.get(pk=dct['responsible'])
new_item = models.Container(**dct)
new_item.save()
return new_item
diff --git a/archaeological_warehouse/tests.py b/archaeological_warehouse/tests.py
index cca1478ee..efe38b4a3 100644
--- a/archaeological_warehouse/tests.py
+++ b/archaeological_warehouse/tests.py
@@ -24,7 +24,7 @@ from archaeological_finds.tests import FindInit
from ishtar_common.tests import WizardTest, WizardTestFormData as FormData
-from archaeological_warehouse import models, views
+from archaeological_warehouse import models, views, forms
class ContainerWizardCreationTest(WizardTest, FindInit, TestCase):
@@ -75,3 +75,38 @@ class ContainerWizardCreationTest(WizardTest, FindInit, TestCase):
def post_wizard(self):
self.assertEqual(models.Container.objects.count(),
self.container_number + 1)
+
+
+class ContainerFormCreationTest(FindInit, TestCase):
+ fixtures = [settings.ROOT_PATH +
+ '../fixtures/initial_data.json',
+ settings.ROOT_PATH +
+ '../ishtar_common/fixtures/initial_data.json',
+ settings.ROOT_PATH +
+ '../archaeological_files/fixtures/initial_data.json',
+ settings.ROOT_PATH +
+ '../archaeological_operations/fixtures/initial_data-fr.json',
+ settings.ROOT_PATH +
+ '../archaeological_finds/fixtures/initial_data-fr.json',
+ settings.ROOT_PATH +
+ '../archaeological_warehouse/fixtures/initial_data-fr.json',
+ ]
+
+ def testFormCreation(self):
+ main_warehouse = models.Warehouse.objects.create(
+ name="Main",
+ warehouse_type=models.WarehouseType.objects.all()[0]
+ )
+ data = {
+ 'reference': 'hop-ref',
+ "responsible": main_warehouse.pk,
+ "location": main_warehouse.pk,
+ "container_type": models.ContainerType.objects.all()[0].pk
+ }
+ form = forms.ContainerForm(data=data)
+ self.assertTrue(form.is_valid())
+ self.container_number = models.Container.objects.count()
+ self.create_user()
+ form.save(self.user)
+ self.assertEqual(models.Container.objects.count(),
+ self.container_number + 1)