diff options
author | Quentin André <quentin.andre@imt-atlantique.net> | 2021-08-28 01:16:02 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 |
commit | daf84f5465aa3a29e268dc6a2d6b50f64bfae341 (patch) | |
tree | 3a2f1ac43f256fc52a04a0ef67f1ec424d9c94cb /archaeological_finds | |
parent | c1f12a9f4b6d724b6db3bed8e429118288933584 (diff) | |
download | Ishtar-daf84f5465aa3a29e268dc6a2d6b50f64bfae341.tar.bz2 Ishtar-daf84f5465aa3a29e268dc6a2d6b50f64bfae341.zip |
synthethic functions for tests and improvement of their robustness
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/tests.py | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 2fb5bf5f5..1311a72ba 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -2857,35 +2857,9 @@ class TemplateTest(FindInit, TestCase): class SeleniumTestsBaseFinds(SeleniumTests): fixtures = FIND_FIXTURES - def _test_bf(self, i, pks, geojsons, from_search=False): - title = self.selenium.find_element_by_xpath( - '//h3[contains(text(), "Mobilier") or contains(text(), "Find")]' - ) - panel = title.find_element_by_xpath("./..") - if from_search: - tbody = "./form" + "/div" * 7 + "/table/tbody" - else: - tbody = "." + "/div" * 6 + "/table/tbody" - details = panel.find_element_by_xpath( - tbody + "/tr[" + str(i) + ']/td/a[@class="display_details"]' - ) - self.scroll(details) - details.click() - label = None - t = time() - while not label and time() - t < self.waiting_time: - for internalId in self.selenium.find_elements_by_xpath( - '//small[@title="ID interne" or @title="Internal ID"]' - ): - if "Find" in internalId.text: - label = internalId.text - break - label = label.split("-") - self.assertEqual(len(label), 3) - label = label[2] - - bf = models.BaseFind.objects.get(pk=pks[label]) - slug_pk = bf.SLUG + "-" + str(bf.pk) + def _test_bf(self, xpath, slug_pk, geojsons): + self.wait_and_click(xpath) + label = self.label_from_internal_id(slug_pk) bf_base = geojsons[label]["get_polys"] self.assertMap(bf_base, slug_pk) @@ -2899,37 +2873,63 @@ class SeleniumTestsBaseFinds(SeleniumTests): self.assertNotInDOM(get_poly) def test_geo_items(self): - pks, geojsons = self.pks_and_geojson() + geojsons = self.default_geojson() # from operation - for i in range(1, 3): - self.access_from_dropdown('operation') - details = self.selenium.find_element_by_xpath( - "//tbody/tr[" + str(i) + ']/td/a[@class="display_details"]' - ) - self.scroll(details) - details.click() + self.access_from_dropdown("operation") + for ope_pk, ope_xpath in self.pks_and_details_from_table("operation"): + self.access_from_dropdown("operation") + self.wait_and_click(ope_xpath) self.selenium.find_element_by_xpath( - '//ul[@role="tablist"]/li/a[contains(text(), "Mobilier") or contains(text(), "Finds")]' + '//ul[@role="tablist"]/li/a[contains(@id, "finds-tab")][contains(@id, "operation-' + + str(ope_pk) + + '")]' ).click() - for j in range(1, 5): - self._test_bf(j, pks, copy.deepcopy(geojsons)) + for pk, xpath in self.pks_and_details_from_table("find", "operation"): + slug_pk = "find-" + str(pk) + self._test_bf(xpath, slug_pk, copy.deepcopy(geojsons)) # from context record - for i in range(1, 5): - self.access_from_dropdown('record') - details = self.selenium.find_element_by_xpath( - "//tbody/tr[" + str(i) + ']/td/a[@class="display_details"]' - ) - self.scroll(details) - details.click() + self.access_from_dropdown("record") + for cr_pk, cr_xpath in self.pks_and_details_from_table("record"): + self.access_from_dropdown("record") + self.wait_and_click(cr_xpath) + self.selenium.find_element_by_xpath( + '//ul[@role="tablist"]/li/a[contains(@id, "finds-tab")][contains(@id, "contextrecord-' + + str(cr_pk) + + '")]' + ).click() + for pk, xpath in self.pks_and_details_from_table("find", "record"): + slug_pk = "find-" + str(pk) + self._test_bf(xpath, slug_pk, copy.deepcopy(geojsons)) + # from context record from operation + self.access_from_dropdown("operation") + for ope_pk, ope_xpath in self.pks_and_details_from_table("operation"): + self.access_from_dropdown("operation") + self.wait_and_click(ope_xpath) self.selenium.find_element_by_xpath( - '//ul[@role="tablist"]/li/a[contains(text(), "Mobilier") or contains(text(), "Finds")]' + '//ul[@role="tablist"]/li/a[contains(@id, "cr-tab")][contains(@id, "operation-' + + str(ope_pk) + + '")]' ).click() - for j in range(1, 3): - self._test_bf(j, pks, copy.deepcopy(geojsons)) - # from search - for i in range(1, 9): - self.access_from_dropdown('find') - self._test_bf(i, pks, copy.deepcopy(geojsons), from_search=True) - # from bottom table - for i in range(1, 8): - self._test_bf(i, pks, copy.deepcopy(geojsons), from_search=True) + for cr_pk, cr_xpath in self.pks_and_details_from_table( + "record", "operation" + ): + self.wait_and_click(cr_xpath) + self.selenium.find_element_by_xpath( + '//ul[@role="tablist"]/li/a[contains(@id, "finds-tab")][contains(@id, "contextrecord-' + + str(cr_pk) + + '")]' + ).click() + for pk, xpath in self.pks_and_details_from_table("find", "record"): + slug_pk = "find-" + str(pk) + self._test_bf(xpath, slug_pk, copy.deepcopy(geojsons)) + # from search bar + self.access_from_dropdown("find") + from_table = self.pks_and_details_from_table("find") + for pk, xpath in from_table: + self.access_from_dropdown("find") + slug_pk = "find-" + str(pk) + self._test_bf(xpath, slug_pk, copy.deepcopy(geojsons)) + # from bottom table, multiple displays + for pk, xpath in from_table: + slug_pk = "find-" + str(pk) + self._test_bf(xpath, slug_pk, copy.deepcopy(geojsons)) |