diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-06-30 17:26:44 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-06-30 17:26:44 +0200 | 
| commit | ffd57727a66952e12b5236e7567f5fd75eb7e5f8 (patch) | |
| tree | 2b8ab152e92a95948e9a038ebcef815bfd56aa38 /archaeological_operations/tests.py | |
| parent | 2a0842c8ffb0e7eec6b350f9d170670c8376cce8 (diff) | |
| parent | 18995ac80a961083ad986f4abe984fd649ec40e2 (diff) | |
| download | Ishtar-ffd57727a66952e12b5236e7567f5fd75eb7e5f8.tar.bz2 Ishtar-ffd57727a66952e12b5236e7567f5fd75eb7e5f8.zip | |
Merge branch 'master' into develop
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 56 | 
1 files changed, 52 insertions, 4 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index a1c0781fc..230a66beb 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -35,7 +35,7 @@ from archaeological_operations import views  from ishtar_common.models import OrganizationType, Organization, ItemKey, \      ImporterType, IshtarUser, TargetKey, ImporterModel, IshtarSiteProfile, \ -    Town, ImporterColumn, Person, DocumentTemplate +    Town, ImporterColumn, Person, Author, SourceType, AuthorType, DocumentTemplate  from archaeological_context_records.models import Unit  from ishtar_common import forms_common @@ -196,7 +196,7 @@ class ImportOperationTest(ImportTest, TestCase):          # and well imported          last_ope = models.Operation.objects.order_by('-pk').all()[0]          self.assertEqual(last_ope.name, u"Oppìdum de Paris") -        self.assertEqual(last_ope.code_patriarche, 4200) +        self.assertEqual(last_ope.code_patriarche, '4200')          self.assertEqual(last_ope.operation_type.txt_idx, 'prog_excavation')          self.assertEqual(last_ope.periods.count(), 2)          periods = [period.txt_idx for period in last_ope.periods.all()] @@ -319,7 +319,7 @@ class ImportOperationTest(ImportTest, TestCase):                           sorted([p.parcel_number for p in last_parcels]))          self.assertEqual(sections,                           sorted([p.section for p in last_parcels])) -        ope1 = models.Operation.objects.filter(code_patriarche=4200).all()[0] +        ope1 = models.Operation.objects.filter(code_patriarche='4200').all()[0]          towns_ope = ope1.towns.all()          imported = [imp for acc, imp in impt.get_all_imported()]          for p in last_parcels: @@ -332,7 +332,7 @@ class ImportOperationTest(ImportTest, TestCase):                  operation_id=ope1.pk).external_id,              '4200-59350-YY55')          # cached_label update -        ope2 = models.Operation.objects.filter(code_patriarche=4201).all()[0] +        ope2 = models.Operation.objects.filter(code_patriarche='4201').all()[0]          self.assertIn('LILLE', ope2.cached_label.upper())          # delete associated parcel with the import deletion          parcel_count = models.Parcel.objects.count() @@ -1395,3 +1395,51 @@ class OperationAdminActWizardCreationTest(WizardTest, OperationInitTest,      def post_wizard(self):          self.assertEqual(models.AdministrativeAct.objects.count(),                           self.number + 1) + + +class OperationSourceWizardModificationTest(WizardTest, OperationInitTest, +                                            TestCase): +    fixtures = OperationWizardCreationTest.fixtures +    url_name = 'operation_source_modification' +    wizard_name = 'operation_source_wizard' +    steps = views.operation_source_modification_steps +    form_datas = [ +        FormData( +            "Test remove all authors", +            form_datas={ +                'selec-operation_source_modification': {}, +                'source-operation_source_modification': { +                    'title': "New title", +                    'source_type': None, +                    'index': 42 +                }, +                'authors-operation_source_modification': [] +            }, +        ) +    ] + +    def pre_wizard(self): +        ope = self.get_default_operation() +        self.source = models.OperationSource.objects.create( +            title="Old title", source_type=SourceType.objects.all()[0], +            operation=ope +        ) +        author = Author.objects.create( +            author_type=AuthorType.objects.all()[0], +            person=Person.objects.all()[0] +        ) + +        self.source.authors.add(author) + +        data = self.form_datas[0].form_datas +        data['selec-operation_source_modification']['pk'] = self.source.pk + +        data['source-operation_source_modification']['hidden_operation_id'] = \ +            self.source.pk +        data['source-operation_source_modification'][ +            'source_type'] = SourceType.objects.all()[1].pk +        super(OperationSourceWizardModificationTest, self).pre_wizard() + +    def post_wizard(self): +        source = models.OperationSource.objects.get(pk=self.source.pk) +        self.assertEqual(source.authors.count(), 0) | 
