diff options
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 32 | 
1 files changed, 26 insertions, 6 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 8fc567c0d..843743852 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -80,7 +80,6 @@ from ishtar_common.models import (  )  from ishtar_common.models_imports import ImporterDefault, ImporterDefaultValues  from archaeological_files.models import File, FileType -from archaeological_context_records.models import Unit, ContextRecord  from ishtar_common import forms_common  from ishtar_common.tests import ( @@ -102,6 +101,9 @@ from ishtar_common.tests import (  )  from ishtar_common.serializers import restore_serialized +if settings.SELENIUM_TEST: +    from selenium.webdriver.support.wait import WebDriverWait +  class FileInit(object):      def login_as_superuser(self): @@ -323,6 +325,7 @@ class ImportTest(object):          return mcc, form      def init_cr_targetkey(self, imp): +        Unit = apps.get_model("archaeological_context_records", "Unit")          hc = Unit.objects.get(txt_idx="not_in_context").pk          self.set_target_key("unit", "hc", hc, imp=imp)          self.set_target_key("unit", "hors-contexte", hc, imp=imp) @@ -1782,6 +1785,9 @@ class OperationTest(TestCase, OperationInitTest):          self.operations += self.create_operation(self.alt_user, self.orgas[0])          self.item = self.operations[0] +        ContextRecord = apps.get_model( +            "archaeological_context_records", "ContextRecord" +        )          for idx in range(15):              ContextRecord.objects.create(label="CR-{}".format(idx), operation=self.item) @@ -1952,17 +1958,20 @@ class OperationTest(TestCase, OperationInitTest):          init_parcel = self.create_parcel()[0]          operation.parcels.add(init_parcel) -        from archaeological_context_records.models import ContextRecord -          cr_data = {              "label": "Context record",              "operation": operation,              "parcel": init_parcel,              "history_modifier": self.get_default_user(),          } +        ContextRecord = apps.get_model( +            "archaeological_context_records", "ContextRecord" +        )          cr = ContextRecord.objects.create(**cr_data) -        from archaeological_finds.models import BaseFind, Find, MaterialType +        BaseFind = apps.get_model("archaeological_finds", "BaseFind") +        Find = apps.get_model("archaeological_finds", "Find") +        MaterialType = apps.get_model("archaeological_finds", "MaterialType")          bf_data = {              "label": "Base find", @@ -2257,6 +2266,10 @@ class OperationTest(TestCase, OperationInitTest):          WarehouseType = apps.get_model("archaeological_warehouse", "WarehouseType")          Container = apps.get_model("archaeological_warehouse", "Container")          ContainerType = apps.get_model("archaeological_warehouse", "ContainerType") +        ContextRecord = apps.get_model( +            "archaeological_context_records", "ContextRecord" +        ) +        Unit = apps.get_model("archaeological_context_records", "Unit")          operation = self.operations[0]          hc, __ = Unit.objects.get_or_create(txt_idx="not-in-context", order=10)          cr = ContextRecord.objects.create(operation=operation, unit=hc) @@ -3489,7 +3502,9 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):          operation2.operation_code = 42          operation2.save() -        from archaeological_context_records.models import ContextRecord +        ContextRecord = apps.get_model( +            "archaeological_context_records", "ContextRecord" +        )          cr_data = {              "label": "Context record", @@ -3596,6 +3611,9 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):                  operation.parcels.count(), test_object.parcel_number + 1              )              # update the external id on update +            ContextRecord = apps.get_model( +                "archaeological_context_records", "ContextRecord" +            )              cr = ContextRecord.objects.get(pk=self.cr.pk)              test_object.assertEqual(cr.external_id, "codeope42-12345-A1-Context record") @@ -4285,7 +4303,7 @@ class SeleniumTestsOperations(SeleniumTests):          ope_base = geojsons[label]["get_polys"] -        self.WebDriverWait(self.selenium, self.waiting_time).until( +        WebDriverWait(self.selenium, self.waiting_time).until(              lambda driver: driver.find_element_by_xpath(                  '//dl[@class="col-12"]/dt[@id="display-geo-items-for-' + slug_pk + '"]'              ) @@ -4386,6 +4404,8 @@ class SeleniumTestsOperations(SeleniumTests):          self.assertMap(ope_base, slug_pk)      def test_geo_items(self): +        if not settings.SELENIUM_TEST: +            return          geojsons = self.default_geojson()          slug = "operation"          self.access_from_dropdown(slug) | 
