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.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 5eeeb1808..a7ca114f0 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -35,7 +35,7 @@ import models
from archaeological_operations import views
from ishtar_common.models import OrganizationType, Organization, \
- ImporterType, IshtarUser, TargetKey
+ ImporterType, IshtarUser, TargetKey, IshtarSiteProfile
from ishtar_common import forms_common
from ishtar_common.tests import WizardTest, create_superuser, create_user
@@ -498,6 +498,28 @@ class OperationInitTest(object):
def get_default_operation(self):
return self.create_operation()[0]
+ def tearDown(self):
+ # cleanup for further test
+ if hasattr(self, 'user'):
+ self.user.delete()
+ self.user = None
+ # all try/except is necessary for bad migrations on master...
+ # should be removed at the next big version
+ if hasattr(self, 'operations'):
+ for ope in self.operations:
+ try:
+ ope.delete()
+ except:
+ pass
+ self.operations = []
+ if hasattr(self, 'parcels'):
+ for p in self.parcels:
+ try:
+ p.delete()
+ except:
+ pass
+ self.parcels = []
+
class OperationTest(TestCase, OperationInitTest):
fixtures = [settings.ROOT_PATH +
@@ -510,6 +532,7 @@ class OperationTest(TestCase, OperationInitTest):
'../archaeological_operations/fixtures/initial_data-fr.json']
def setUp(self):
+ IshtarSiteProfile.objects.create()
self.username, self.password, self.user = create_superuser()
self.alt_username, self.alt_password, self.alt_user = create_user()
self.alt_user.user_permissions.add(Permission.objects.get(
@@ -519,6 +542,26 @@ class OperationTest(TestCase, OperationInitTest):
self.operations += self.create_operation(self.alt_user, self.orgas[0])
self.item = self.operations[0]
+ def testExternalID(self):
+ self.item.code_patriarche = '123456789'
+ self.item.save()
+ parcel = self.get_default_parcel()
+ parcel.operation = self.item
+ parcel.save()
+ correct_ext_id = u"{}-{}-{}{}".format(
+ self.item.code_patriarche, parcel.town.numero_insee,
+ parcel.section, parcel.parcel_number)
+ self.assertEqual(parcel.external_id, correct_ext_id)
+ # auto has been previously set
+ parcel.external_id = 'blabla'
+ parcel.save()
+ self.assertEqual(parcel.external_id, correct_ext_id)
+ # deactivate auto
+ parcel.auto_external_id = False
+ parcel.external_id = 'blabla'
+ parcel.save()
+ self.assertEqual(parcel.external_id, 'blabla')
+
def testSearch(self):
c = Client()
response = c.get(reverse('get-operation'), {'year': '2010'})