summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py69
1 files changed, 67 insertions, 2 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index a0a9f0a8a..181ca12d0 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -23,12 +23,15 @@ from django.test import TestCase
from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\
FormaterType, ImportTarget
-from archaeological_finds import models
+from ishtar_common.models import Person
+from archaeological_finds import models, views
+from archaeological_warehouse.models import Warehouse, WarehouseType
from archaeological_context_records.tests import ImportContextRecordTest, \
ContextRecordInit
from ishtar_common import forms_common
+from ishtar_common.tests import WizardTest, WizardTestFormData as FormData
class ImportFindTest(ImportContextRecordTest):
@@ -201,12 +204,13 @@ class PackagingTest(FindInit, TestCase):
def testPackaging(self):
treatment_type = models.TreatmentType.objects.get(txt_idx='packaging')
- treatment = models.Treatment(treatment_type=treatment_type)
+ treatment = models.Treatment()
items_nb = models.Find.objects.count()
treatment.save(user=self.get_default_user(), items=self.basket)
self.assertEqual(items_nb + self.basket.items.count(),
models.Find.objects.count(),
msg="Packaging doesn't generate enough new finds")
+ treatment.treatment_types.add(treatment_type)
# new version of the find is in the basket
for item in self.basket.items.all():
self.assertNotIn(
@@ -216,3 +220,64 @@ class PackagingTest(FindInit, TestCase):
self.assertNotIn(
item, self.finds,
msg="Other basket have not been upgraded after packaging")
+
+
+class TreatmentWizardCreationTest(WizardTest, 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',
+ ]
+ url_name = 'treatment_creation'
+ wizard_name = 'treatment_wizard'
+ steps = views.treatment_wizard_steps
+ form_datas = [
+ FormData(
+ 'Move treament',
+ form_datas={
+ 'basetreatment-treatment_creation': {
+ 'treatment_type': 4, # move
+ 'person': 1, # doer
+ 'location': 1, # associated warehouse
+ 'year': 2016,
+ 'target_is_basket': False
+ },
+ 'selecfind-treatment_creation': {
+ 'pk': 1,
+ 'resulting_pk': 1
+ }
+ },
+ ignored=('resultfind-treatment_creation',
+ 'selecbasket-treatment_creation',
+ 'resultfinds-treatment_creation'))
+ ]
+
+ def pre_wizard(self):
+ q = Warehouse.objects.filter(pk=1)
+ if not q.count():
+ warehouse = Warehouse.objects.create(
+ name="default", warehouse_type=WarehouseType.objects.all()[0])
+ warehouse.id = 1
+ warehouse.save()
+ q = Person.objects.filter(pk=1)
+ if not q.count():
+ person = Person.objects.create(name="default")
+ person.id = 1
+ person.save()
+ if not models.Find.objects.filter(pk=1).count():
+ self.create_finds({"pk": 1, "label": u"Find 1"}, force=True)
+ self.treatment_number = models.Treatment.objects.count()
+ super(TreatmentWizardCreationTest, self).pre_wizard()
+
+ def post_wizard(self):
+ self.assertEqual(models.Treatment.objects.count(),
+ self.treatment_number + 1)
+ pass