summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py114
1 files changed, 77 insertions, 37 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index dd294550e..d8399eedb 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -38,7 +38,8 @@ from ishtar_common.models import OrganizationType, Organization, \
ImporterType, IshtarUser, TargetKey, IshtarSiteProfile
from ishtar_common import forms_common
-from ishtar_common.tests import WizardTest, create_superuser, create_user
+from ishtar_common.tests import WizardTest, WizardTestFormData as FormData, \
+ create_superuser, create_user
class ImportOperationTest(TestCase):
@@ -481,7 +482,9 @@ class OperationInitTest(object):
self.parcels.append(models.Parcel.objects.create(**default))
return self.parcels
- def get_default_parcel(self):
+ def get_default_parcel(self, force=False):
+ if force:
+ return self.create_parcel()[-1]
return self.create_parcel()[0]
def create_operation(self, user=None, orga=None):
@@ -495,6 +498,8 @@ class OperationInitTest(object):
return self.operations
def get_default_operation(self, force=False):
+ if force:
+ return self.create_operation()[-1]
return self.create_operation()[0]
def tearDown(self):
@@ -668,20 +673,20 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
url_name = 'operation_creation'
wizard_name = 'operation_wizard'
steps = views.wizard_steps
- form_datas = [(
- # data
- {
- 'general-operation_creation': {
- 'operation_type': 1, # preventive diag
- 'year': 2016}
- },
- # ignored
- ('filechoice-operation_creation',
- 'preventive-operation_creation',
- 'towns-operation_creation',
- 'parcels-operation_creation',
- )
- )]
+ form_datas = [
+ FormData(
+ "Create a preventive diag",
+ form_datas={
+ 'general-operation_creation': {
+ 'operation_type': 1, # preventive diag
+ 'year': 2016}
+ },
+ ignored=('filechoice-operation_creation',
+ 'preventive-operation_creation',
+ 'towns-operation_creation',
+ 'parcels-operation_creation', )
+ )
+ ]
def pre_wizard(self):
self.operation_number = models.Operation.objects.count()
@@ -692,20 +697,56 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
self.operation_number + 1)
+class OperationWizardDeleteTest(OperationWizardCreationTest):
+ fixtures = OperationWizardCreationTest.fixtures
+ url_name = 'operation_deletion'
+ wizard_name = 'operation_deletion_wizard'
+ steps = views.operation_deletion_steps
+ form_datas = [
+ FormData(
+ "Wizard deletion test",
+ form_datas={
+ 'selec-operation_deletion': {'pk': None},
+ }
+ )
+ ]
+
+ def pass_test(self):
+ if not settings.SOUTH_TESTS_MIGRATE:
+ # with no migration the views are not created
+ return True
+
+ def pre_wizard(self):
+ self.ope = self.get_default_operation(force=True)
+ self.form_datas[0].form_datas['selec-operation_deletion']['pk'] = \
+ self.ope.pk
+ self.operation_number = models.Operation.objects.count()
+ super(OperationWizardDeleteTest, self).pre_wizard()
+
+ def post_wizard(self):
+ self.assertEqual(self.operation_number - 1,
+ models.Operation.objects.count())
+
+
class OperationWizardClosingTest(OperationWizardCreationTest):
fixtures = OperationWizardCreationTest.fixtures
url_name = 'operation_closing'
wizard_name = 'operation_closing_wizard'
steps = views.operation_closing_steps
- form_datas = [[
- {
- 'selec-operation_closing': {'pk': None},
- 'date-operation_closing': {'end_date': '2016-01-01'},
- }, []]]
+ form_datas = [
+ FormData(
+ "Wizard closing test",
+ form_datas={
+ 'selec-operation_closing': {'pk': None},
+ 'date-operation_closing': {'end_date': '2016-01-01'},
+ }
+ )
+ ]
def pre_wizard(self):
self.ope = self.get_default_operation()
- self.form_datas[0][0]['selec-operation_closing']['pk'] = self.ope.pk
+ self.form_datas[0].form_datas['selec-operation_closing']['pk'] = \
+ self.ope.pk
self.assertTrue(self.ope.is_active())
super(OperationWizardClosingTest, self).pre_wizard()
@@ -714,7 +755,7 @@ class OperationWizardClosingTest(OperationWizardCreationTest):
self.assertFalse(ope.is_active())
self.assertEqual(
ope.closing()['date'].strftime('%Y-%d-%m'),
- self.form_datas[0][0]['date-operation_closing']['end_date'])
+ self.form_datas[0].form_datas['date-operation_closing']['end_date'])
class OperationAdminActWizardCreationTest(WizardTest, OperationInitTest,
@@ -730,25 +771,24 @@ class OperationAdminActWizardCreationTest(WizardTest, OperationInitTest,
url_name = 'operation_administrativeactop'
wizard_name = 'operation_administrative_act_wizard'
steps = views.administrativeactop_steps
- form_datas = [[
- # data
- {
- 'selec-operation_administrativeactop': {
- },
- 'administrativeact-operation_administrativeactop': {
- 'signature_date': str(datetime.date.today())
- }
- },
- # ignored
- []
- ]]
+ form_datas = [
+ FormData(
+ "Admin act creation",
+ form_datas={
+ 'selec-operation_administrativeactop': {
+ },
+ 'administrativeact-operation_administrativeactop': {
+ 'signature_date': str(datetime.date.today())
+ }
+ },
+ )
+ ]
def pre_wizard(self):
ope = self.get_default_operation()
-
self.number = models.AdministrativeAct.objects.count()
- data = self.form_datas[0][0]
+ data = self.form_datas[0].form_datas
data['selec-operation_administrativeactop']['pk'] = ope.pk
act = models.ActType.objects.filter(intented_to='O').all()[0].pk