diff options
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 437 |
1 files changed, 360 insertions, 77 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index a475667b1..0d6908374 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -19,12 +19,16 @@ import json import datetime +import StringIO +import zipfile from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse +from django.db.models import Q from django.test.client import Client +from django.contrib.auth.models import User from django.contrib.auth.models import Permission import models @@ -32,7 +36,9 @@ from archaeological_operations import views from ishtar_common.models import OrganizationType, Organization, ItemKey, \ ImporterType, IshtarUser, TargetKey, ImporterModel, IshtarSiteProfile, \ - Town, ImporterColumn, Person, Author, SourceType, AuthorType + Town, ImporterColumn, Person, Author, SourceType, AuthorType, \ + DocumentTemplate, PersonType, TargetKeyGroup +from archaeological_files.models import File, FileType from archaeological_context_records.models import Unit from ishtar_common import forms_common @@ -45,11 +51,46 @@ OPERATION_TOWNS_FIXTURES = \ FILE_FIXTURES = OPERATION_FIXTURES + [ settings.ROOT_PATH + - '../archaeological_files/fixtures/initial_data.json'] + '../archaeological_files/fixtures/initial_data-fr.json'] FILE_TOWNS_FIXTURES = OPERATION_TOWNS_FIXTURES + [ settings.ROOT_PATH + - '../archaeological_files/fixtures/initial_data.json'] + '../archaeological_files/fixtures/initial_data-fr.json'] + + +class FileInit(object): + def login_as_superuser(self): + self.client.login(username='username', password='tralala') + + def create_file(self): + self.extra_models, self.model_list = {}, [] + self.user, created = User.objects.get_or_create(username='username', + is_superuser=True) + self.user.set_password('tralala') + self.user.save() + self.o_user, created = User.objects.get_or_create(username='ousername') + person_type, created = PersonType.objects.get_or_create( + label=u'Test ' u'person type', txt_idx='test_person', + available=True) + self.extra_models['person_type'] = person_type + self.model_list.append(person_type) + + person = models.Person(surname='Surname', name='Name', + history_modifier=self.o_user) + person.save() + self.extra_models['person'] = person + self.model_list.append(person) + + file_type, created = FileType.objects.get_or_create( + label=u'Test file type', txt_idx='test_file', available=True) + self.extra_models['file_type'] = file_type + self.model_list.append(file_type) + + dct = {'year': 2010, 'numeric_reference': 1000, 'file_type': file_type, + 'internal_reference': u'UNIT_testÉ ?', 'in_charge': person, + 'history_modifier': self.o_user, 'total_surface': 10000} + self.item = File(**dct) + self.item.save() class ImportTest(object): @@ -74,14 +115,24 @@ class ImportTest(object): 'rb') file_dict = {'imported_file': SimpleUploadedFile( mcc_operation_file.name, mcc_operation_file.read())} + group, c = TargetKeyGroup.objects.get_or_create(name="My group") post_dict = {'importer_type': mcc_operation.pk, 'skip_lines': 1, - "encoding": 'utf-8'} - form = forms_common.NewImportForm(data=post_dict, files=file_dict) + "encoding": 'utf-8', "name": 'init_ope_import', + "associated_group": group.pk} + form = forms_common.NewImportForm(data=post_dict, files=file_dict, + user=self.user) form.is_valid() return mcc_operation, form def init_ope_targetkey(self, imp): # doing manually connections + q = Q(importer=imp) | Q(user=imp.user) + if imp.associated_group: + q |= Q(group=imp.associated_group) + for ik in ItemKey.objects.filter(q).all(): + ik.delete() + + # target for this import target = TargetKey.objects.filter( target__target='operation_type').order_by('-pk').all()[0] target.value = models.OperationType.objects.get( @@ -90,22 +141,61 @@ class ImportTest(object): target.associated_import = imp target.save() - target2 = TargetKey.objects.get(key='gallo-romain', - associated_import=imp) + # target for all users + tgs = list(TargetKey.objects.filter(key='gallo-romain').all()) + for tg in tgs[1:]: + tg.delete() + target2 = tgs[0] gallo = models.Period.objects.get(txt_idx='gallo-roman') target2.value = gallo.pk target2.is_set = True - target2.associated_import = imp + target2.associated_import = None + target2.associated_group = None + target2.associated_user = None target2.save() - target3 = TargetKey.objects.get(key='age-du-fer', - associated_import=imp) + # target for this user + tgs = list(TargetKey.objects.filter(key='age-du-fer').all()) + for tg in tgs[1:]: + tg.delete() + target3 = tgs[0] iron = models.Period.objects.get(txt_idx='iron_age') target3.value = iron.pk target3.is_set = True - target3.associated_import = imp + target3.associated_import = None + target3.associated_user = self.ishtar_user + target3.associated_group = None target3.save() - return [target, target2, target3] + + # target for another user + username, password, user = create_user() + another_user = IshtarUser.objects.get(pk=user.pk) + tgs = list(TargetKey.objects.filter(key='neolithik').all()) + for tg in tgs[1:]: + tg.delete() + target4 = tgs[0] + neo = models.Period.objects.get(txt_idx='neolithic') + target4.value = neo.pk + target4.is_set = True + target4.associated_import = None + target4.associated_group = None + target4.associated_user = another_user + target4.save() + + # target for the current group + tgs = list(TargetKey.objects.filter(key='moderne').all()) + for tg in tgs[1:]: + tg.delete() + target5 = tgs[0] + modern = models.Period.objects.get(txt_idx='modern') + target5.value = modern.pk + target5.is_set = True + target5.associated_import = None + target5.associated_user = None + target5.associated_group = imp.associated_group + target5.save() + + return [target, target2, target3, target4, target5] def init_ope(self): importer, form = self.init_ope_import() @@ -124,8 +214,9 @@ class ImportTest(object): file_dict = {'imported_file': SimpleUploadedFile(mcc_file.name, mcc_file.read())} post_dict = {'importer_type': mcc_parcel.pk, 'skip_lines': 1, - "encoding": 'utf-8'} - form = forms_common.NewImportForm(data=post_dict, files=file_dict) + "encoding": 'utf-8', "name": 'init_parcel_import'} + form = forms_common.NewImportForm(data=post_dict, files=file_dict, + user=self.user) form.is_valid() return mcc_parcel, form @@ -145,8 +236,9 @@ class ImportTest(object): file_dict = {'imported_file': SimpleUploadedFile(mcc_file.name, mcc_file.read())} post_dict = {'importer_type': mcc.pk, 'skip_lines': 1, - "encoding": 'utf-8'} - form = forms_common.NewImportForm(data=post_dict, files=file_dict) + "encoding": 'utf-8', "name": 'init_context_record_import'} + form = forms_common.NewImportForm(data=post_dict, files=file_dict, + user=self.user) form.is_valid() return mcc, form @@ -169,8 +261,11 @@ class ImportOperationTest(ImportTest, TestCase): fixtures = OPERATION_TOWNS_FIXTURES def test_mcc_import_operation(self): - first_ope_nb = models.Operation.objects.count() + create_user() # create it before import to have a relevant person + # number first_person_nb = Person.objects.count() + first_ope_nb = models.Operation.objects.count() + importer, form = self.init_ope_import() self.assertTrue(form.is_valid()) impt = form.save(self.ishtar_user) @@ -198,10 +293,13 @@ class ImportOperationTest(ImportTest, TestCase): self.assertEqual(last_ope.name, u"Oppìdum de Paris") self.assertEqual(last_ope.code_patriarche, '4200') self.assertEqual(last_ope.operation_type.txt_idx, 'prog_excavation') - self.assertEqual(last_ope.periods.count(), 2) + + self.assertEqual(last_ope.periods.count(), 3) periods = [period.txt_idx for period in last_ope.periods.all()] self.assertIn('iron_age', periods) self.assertIn('gallo-roman', periods) + # target key set for another user + self.assertNotIn('neolithic', periods) # a second importation will be not possible: no two same patriarche # code @@ -213,7 +311,7 @@ class ImportOperationTest(ImportTest, TestCase): self.init_ope_import('MCC-operations-example-bad-encoding.csv') def test_keys_limitation(self): - # each key association is associated to the import + # each key association associated to the import init_ope_number = models.Operation.objects.count() importer, form = self.init_ope_import() impt = form.save(self.ishtar_user) @@ -222,16 +320,32 @@ class ImportOperationTest(ImportTest, TestCase): importer, form = self.init_ope_import() other_imp = form.save(self.ishtar_user) - # associate with another import - for ik in ItemKey.objects.filter(importer=impt).all(): - ik.importer = other_imp - ik.save() + + # re-associate with another import + q = Q(importer=impt) | Q(user=impt.user) + if impt.associated_group: + q |= Q(group=impt.associated_group) + for ik in ItemKey.objects.filter(q).all(): + ik.delete() + + q = Q(associated_import=impt) | Q(associated_user=impt.user) + if impt.associated_group: + q |= Q(associated_group=impt.associated_group) + for tg in TargetKey.objects.filter(q).all(): + tg.associated_user = None + tg.associated_group = None + tg.associated_import = other_imp + tg.save() impt.importation() current_ope_nb = models.Operation.objects.count() # no new operation self.assertEqual(current_ope_nb, init_ope_number) + for tg in TargetKey.objects.filter(associated_import=other_imp).all(): + tg.associated_import = impt + tg.save() + def test_bad_configuration(self): importer, form = self.init_ope_import() col = ImporterColumn.objects.get(importer_type=importer, col_number=1) @@ -247,7 +361,8 @@ class ImportOperationTest(ImportTest, TestCase): self.assertEqual(len(impt.errors), 2) self.assertTrue( "Importer configuration error" in impt.errors[0]['error'] or - "Erreur de configuration de l\'importeur" in impt.errors[0]['error'] + "Erreur de configuration de l\'importeur" in + impt.errors[0]['error'] ) def test_model_limitation(self): @@ -575,7 +690,9 @@ def create_orga(user): def create_operation(user, orga=None, values={}): - dct = {'year': 2010, 'operation_type_id': 1, + operation_type = models.OperationType.objects.get( + txt_idx="arch_diagnostic") + dct = {'year': 2010, 'operation_type_id': operation_type.pk, 'history_modifier': user} dct.update(values) if orga: @@ -587,11 +704,13 @@ def create_operation(user, orga=None, values={}): class OperationInitTest(object): def create_user(self): username, password, self.user = create_user() + return self.user def get_default_user(self): - if not hasattr(self, 'user') or not self.user: - self.create_user() - return self.user + q = User.objects.filter(is_superuser=False) + if q.count(): + return q.all()[0] + return self.create_user() def create_orgas(self, user=None): if not user: @@ -864,16 +983,37 @@ class OperationTest(TestCase, OperationInitTest): def test_show(self): operation = self.operations[0] + source = models.OperationSource.objects.create( + operation=operation, title="Source title", + source_type=models.SourceType.objects.all()[0] + ) c = Client() + response = c.get(reverse('show-operation', kwargs={'pk': operation.pk})) self.assertEqual(response.status_code, 200) # empty content when not allowed self.assertEqual(response.content, "") + response = c.get(reverse('show-operationsource', + kwargs={'pk': source.pk})) + self.assertEqual(response.status_code, 200) + # empty content when not allowed + self.assertEqual(response.content, "") c.login(username=self.username, password=self.password) response = c.get(reverse('show-operation', kwargs={'pk': operation.pk})) self.assertEqual(response.status_code, 200) self.assertIn('class="sheet"', response.content) + response = c.get(reverse('show-operationsource', + kwargs={'pk': source.pk})) + self.assertEqual(response.status_code, 200) + self.assertIn('class="sheet"', response.content) + + response = c.get(reverse('show-operation', kwargs={'pk': operation.pk, + 'type': 'odt'})) + self.assertEqual(response.status_code, 200) + f = StringIO.StringIO(response.content) + z = zipfile.ZipFile(f) + self.assertIsNone(z.testzip()) class OperationSearchTest(TestCase, OperationInitTest): @@ -978,9 +1118,28 @@ class OperationSearchTest(TestCase, OperationInitTest): self.assertTrue(json.loads(response.content)['total'] == 1) +class DashboardTest(TestCase, OperationInitTest): + fixtures = FILE_FIXTURES + + def setUp(self): + IshtarSiteProfile.objects.get_or_create( + slug='default', active=True) + self.username, self.password, self.user = create_superuser() + self.orgas = self.create_orgas(self.user) + self.operations = self.create_operation(self.user, self.orgas[0]) + + def test_dashboard(self): + url = 'dashboard-operation' + c = Client() + c.login(username=self.username, password=self.password) + + response = c.get(reverse(url)) + self.assertEqual(response.status_code, 200) + + def create_administrativact(user, operation): act_type, created = models.ActType.objects.get_or_create( - txt_idx='act_type') + txt_idx='act_type_O', intented_to='O') dct = {'history_modifier': user, 'act_type': act_type, 'operation': operation, @@ -996,7 +1155,7 @@ class RegisterTest(TestCase, OperationInitTest): def setUp(self): self.username, self.password, self.user = create_superuser() self.operations = self.create_operation(self.user) - self.act_types, self.operations = create_administrativact( + self.act_types, self.admin_acts = create_administrativact( self.user, self.operations[0]) def testSearch(self): @@ -1010,6 +1169,70 @@ class RegisterTest(TestCase, OperationInitTest): response = c.get(reverse('get-administrativeact'), {'indexed': '2'}) self.assertTrue(json.loads(response.content)['total'] == 1) + def test_document_generation(self): + tpl = open( + settings.ROOT_PATH + + '../archaeological_operations/tests/document_reference.odt', + 'rb') + template = SimpleUploadedFile(tpl.name, tpl.read()) + doc = DocumentTemplate.objects.create( + name="Test", + associated_object_name=DocumentTemplate.CLASSNAMES[0][0], + available=True, + template=template + ) + self.act_types[0].associated_template.add(doc) + + c = Client() + data = {'pk': self.admin_acts[0].pk, 'document_template': doc.pk} + response = c.post(reverse('operation-administrativeact-document'), data) + # no result when no authentication + self.assertEqual(response.content, "") + c.login(username=self.username, password=self.password) + response = c.post(reverse('operation-administrativeact-document'), data) + try: + f = StringIO.StringIO(response.content) + z = zipfile.ZipFile(f) + self.assertIsNone(z.testzip()) + content = z.open('content.xml') + self.assertIn('2014-05-12', content.read()) + finally: + content.close() + z.close() + f.close() + + def test_document_migration(self): + fe = FileInit() + fe.create_file() + + from archaeological_files.tests import create_administrativact as ca_fle + ca_fle(self.user, fe.item) + + tpl = open( + settings.ROOT_PATH + + '../ishtar_common/tests/old.odt', + 'rb') + template = SimpleUploadedFile(tpl.name, tpl.read()) + doc = DocumentTemplate.objects.create( + name="Old", + associated_object_name=DocumentTemplate.CLASSNAMES[0][0], + available=True, + template=template + ) + self.act_types[0].associated_template.add(doc) + + doc.convert_from_v1() + with open(doc.template.path) as f: + try: + z = zipfile.ZipFile(f) + self.assertIsNone(z.testzip()) + c = z.open('content.xml') + content = c.read() + self.assertIn('{{ adminact_operator_id }}', content) + finally: + c.close() + z.close() + class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): fixtures = FILE_FIXTURES @@ -1020,31 +1243,48 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): FormData( "Create a preventive diag", form_datas={ - 'filechoice-operation_creation': {}, - 'general-operation_creation': { - 'operation_type': 1, # preventive diag + 'filechoice': {}, + 'general': { + 'code_patriarche': 'codeope1', + 'operation_type': None, 'year': 2016}, - 'townsgeneral-operation_creation': [], - 'parcelsgeneral-operation_creation': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=('towns-operation_creation', 'parcels-operation_creation', - 'preventive-operation_creation',) + 'preventive-operation_creation') ), FormData( "Create another preventive diag with same parcel name", form_datas={ - 'filechoice-operation_creation': {}, - 'general-operation_creation': { - 'operation_type': 1, # preventive diag + 'filechoice': {}, + 'general': { + 'code_patriarche': 'codeope2', + 'operation_type': None, 'year': 2016}, - 'townsgeneral-operation_creation': [], - 'parcelsgeneral-operation_creation': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=('towns-operation_creation', 'parcels-operation_creation', - 'preventive-operation_creation',) - ) + 'preventive-operation_creation') + ), + FormData( + "Create an operation related to a file", + form_datas={ + 'filechoice': {}, + 'general': { + 'code_patriarche': 'codeope3', + 'operation_type': None, + 'year': 2016}, + 'towns': [], + 'parcels': [], + }, + ignored=('townsgeneral-operation_creation', + 'parcelsgeneral-operation_creation', + 'preventive-operation_creation') + ), ] def pre_wizard(self): @@ -1053,31 +1293,59 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): profile.files = True profile.save() - if 'townsgeneral-operation_creation' not in \ + if 'townsgeneral' not in \ self.form_datas[0].form_datas: return super(OperationWizardCreationTest, self).pre_wizard() town = self.create_towns()[0] town_data = {'town': town.pk} self.form_datas[0].form_datas[ - 'townsgeneral-operation_creation'].append(town_data) + 'townsgeneral'].append(town_data) self.form_datas[1].form_datas[ - 'townsgeneral-operation_creation'].append(town_data) + 'townsgeneral'].append(town_data) parcel_data = { 'town': town.pk, 'year': 2017, 'section': 'S', 'parcel_number': '42'} self.form_datas[0].form_datas[ - 'parcelsgeneral-operation_creation'].append(parcel_data) + 'parcelsgeneral'].append(parcel_data) self.form_datas[1].form_datas[ - 'parcelsgeneral-operation_creation'].append(parcel_data) + 'parcelsgeneral'].append(parcel_data) + + FI = FileInit() + FI.create_file() + file = FI.item + file.towns.add(town) + parcel = models.Parcel.objects.create( + town=town, year=2017, section='G', parcel_number='43' + ) + file.parcels.add(parcel) + self.form_datas[2].set('filechoice', 'associated_file', file.pk) + self.form_datas[2].append('towns', town_data) + self.form_datas[2].append('parcels', {'parcel': parcel.pk}) + + # diagnostic + ope_type = models.OperationType.objects.get(txt_idx='arch_diagnostic') + self.form_datas[0].set('general', 'operation_type', ope_type.pk) + self.form_datas[1].set('general', 'operation_type', ope_type.pk) + self.form_datas[2].set('general', 'operation_type', ope_type.pk) + self.operation_number = models.Operation.objects.count() self.parcel_number = models.Parcel.objects.count() super(OperationWizardCreationTest, self).pre_wizard() def post_wizard(self): self.assertEqual(models.Operation.objects.count(), - self.operation_number + 2) + self.operation_number + 3) + operations = models.Operation.objects.order_by("-pk").all()[:3] + + parcel_ids = [] + for operation in operations: + for parcel in operation.parcels.all(): + parcel_ids.append(parcel.external_id) + self.assertEqual(list(sorted(parcel_ids)), + ['codeope1-12345-S42', 'codeope2-12345-S42', + 'codeope3-12345-G43']) self.assertEqual(models.Parcel.objects.count(), - self.parcel_number + 2) + self.parcel_number + 3) class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): @@ -1099,36 +1367,37 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): FormData( "Update an operation", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), FormData( "Operation: try to remove a parcel with attached context record", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { + 'code_patriarche': "codeope42", 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), FormData( "Operation: remove a parcel with no attached context record", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), @@ -1148,33 +1417,40 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): 'history_modifier': self.get_default_user()} self.cr = ContextRecord.objects.create(**cr_data) + # diagnostic + self.ope_type = models.OperationType.objects.get( + txt_idx='prev_excavation') + self.form_datas[0].set('general', 'operation_type', self.ope_type.pk) + self.form_datas[1].set('general', 'operation_type', self.ope_type.pk) + self.form_datas[2].set('general', 'operation_type', self.ope_type.pk) + data = self.form_datas[0].form_datas data2 = self.form_datas[1].form_datas data3 = self.form_datas[2].form_datas - data['selec-operation_modification']['pk'] = operation.pk - data2['selec-operation_modification']['pk'] = operation.pk - data3['selec-operation_modification']['pk'] = operation.pk + data['selec']['pk'] = operation.pk + data2['selec']['pk'] = operation.pk + data3['selec']['pk'] = operation.pk town = self.create_towns( datas={'numero_insee': '67890', 'name': 'Twin Peaks'})[-1] towns = [{'town': town.pk}, {'town': init_town.pk}] - data['townsgeneral-operation_modification'] = towns - data2['townsgeneral-operation_modification'] = towns - data3['townsgeneral-operation_modification'] = towns + data['townsgeneral'] = towns + data2['townsgeneral'] = towns + data3['townsgeneral'] = towns parcel_data = { 'town': town.pk, 'year': 2017, 'section': 'S', 'parcel_number': '42'} - data['parcelsgeneral-operation_modification'].append(parcel_data) - data2['parcelsgeneral-operation_modification'].append(parcel_data) - data3['parcelsgeneral-operation_modification'].append(parcel_data) + data['parcelsgeneral'].append(parcel_data) + data2['parcelsgeneral'].append(parcel_data) + data3['parcelsgeneral'].append(parcel_data) parcel_data_2 = { 'town': init_parcel.town.pk, 'year': init_parcel.year or '', 'section': init_parcel.section, 'parcel_number': init_parcel.parcel_number} - data['parcelsgeneral-operation_modification'].append(parcel_data_2) + data['parcelsgeneral'].append(parcel_data_2) # no init parcel for data2 and data3 self.operation_number = models.Operation.objects.count() @@ -1185,7 +1461,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + test_object.assertEqual(operation.operation_type.pk, + self.ope_type.pk) test_object.assertEqual(operation.year, 2017) test_object.assertEqual(models.Parcel.objects.count(), test_object.parcel_number + 1) @@ -1197,7 +1474,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + test_object.assertEqual(operation.operation_type.pk, + self.ope_type.pk) test_object.assertEqual(operation.year, 2017) test_object.assertEqual(models.Parcel.objects.count(), test_object.parcel_number + 1) @@ -1205,6 +1483,10 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): # the init parcel is not detached from the operation test_object.assertEqual(operation.parcels.count(), test_object.parcel_number + 1) + # update teh external id on update + cr = ContextRecord.objects.get(pk=self.cr.pk) + test_object.assertEqual(cr.external_id, + "codeope42-12345-A1-Context record") def pre_third_wizard(test_object): parcel_nb = models.Parcel.objects.count() @@ -1217,7 +1499,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + test_object.assertEqual(operation.operation_type.pk, + self.ope_type.pk) test_object.assertEqual(operation.year, 2017) # with no attach the parcel is deleted test_object.assertEqual(operation.parcels.count(), @@ -1247,7 +1530,7 @@ class OperationWizardDeleteTest(OperationWizardCreationTest): ] def pass_test(self): - if not settings.SOUTH_TESTS_MIGRATE: + if not settings.TEST_VIEWS: # with no migration the views are not created return True @@ -1378,4 +1661,4 @@ class OperationSourceWizardModificationTest(WizardTest, OperationInitTest, def post_wizard(self): source = models.OperationSource.objects.get(pk=self.source.pk) - self.assertEqual(source.authors.count(), 0)
\ No newline at end of file + self.assertEqual(source.authors.count(), 0) |