diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-08-31 16:54:34 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:03 +0200 |
commit | 2b60ed096578912270e393c1c4e8d7516dea70a7 (patch) | |
tree | 74c2c2e97a26b960ed7803db499f2da205bbe718 /archaeological_operations | |
parent | 24a7285d40b4268d53bcf4adcdeb88a5186efb2c (diff) | |
download | Ishtar-2b60ed096578912270e393c1c4e8d7516dea70a7.tar.bz2 Ishtar-2b60ed096578912270e393c1c4e8d7516dea70a7.zip |
Tests: clean imports
Diffstat (limited to 'archaeological_operations')
-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 4112fc91b..b9326fa22 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -79,7 +79,6 @@ from ishtar_common.models import ( Regexp, ) 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 ( @@ -101,6 +100,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): @@ -322,6 +324,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) @@ -1759,6 +1762,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) @@ -1929,17 +1935,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", @@ -2234,6 +2243,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) @@ -3456,7 +3469,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", @@ -3555,6 +3570,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") @@ -4230,7 +4248,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 + '"]' ) @@ -4331,6 +4349,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) |