summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
authorQuentinAndre <quentin.andre@imt-atlantique.net>2021-08-28 01:16:02 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-25 12:06:03 +0200
commit24a7285d40b4268d53bcf4adcdeb88a5186efb2c (patch)
tree217459aefae410f67b8603dca9520a3e7f1412d7 /archaeological_context_records/tests.py
parente43dd55eb521b7052e2faea172cf3770b0d76892 (diff)
downloadIshtar-24a7285d40b4268d53bcf4adcdeb88a5186efb2c.tar.bz2
Ishtar-24a7285d40b4268d53bcf4adcdeb88a5186efb2c.zip
synthethic functions for tests and improvement of their robustness
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r--archaeological_context_records/tests.py75
1 files changed, 25 insertions, 50 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index a99fbefe6..85011a7bf 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -1380,40 +1380,9 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
class SeleniumTestsContextRecords(SeleniumTests):
fixtures = CONTEXT_RECORD_FIXTURES
- def _test_cr(self, i, pks, geojsons, method=None):
- if method == "from operation":
- tbody = "." + "/div" * 6 + "/table/tbody"
- title = self.selenium.find_element_by_xpath(
- '//h3[contains(text(), "Unité d\'Enregistrement") or contains(text(), "Context record")]'
- )
- panel = title.find_element_by_xpath("./..")
- details = panel.find_element_by_xpath(
- tbody + "/tr[" + str(i) + ']/td/a[@class="display_details"]'
- )
- self.scroll(details)
- label = panel.find_element_by_xpath(
- tbody + "/tr[" + str(i) + "]/td[2]"
- ).text
- details.click()
- else:
- tbody = "./form" + "/div" * 7 + "/table/tbody"
- title = '//h3[text()="Rechercher une unité d\'enregistrement" or text()="Context record search"]'
- self.WebDriverWait(self.selenium, self.waiting_time).until(
- lambda driver: driver.find_element_by_xpath(title)
- )
- title = self.selenium.find_element_by_xpath(title)
- panel = title.find_element_by_xpath("./..")
- details = panel.find_element_by_xpath(
- tbody + "/tr[" + str(i) + ']/td/a[@class="display_details"]'
- )
- self.scroll(details)
- details.click()
- label = self.selenium.find_element_by_xpath(
- '//small[@title="ID interne" or @title="Internal ID"]'
- ).text
- label = label[1:]
- cr = models.ContextRecord.objects.get(pk=pks[label])
- slug_pk = str(cr.SLUG) + "-" + str(cr.pk)
+ def _test_cr(self, xpath, slug_pk, geojsons):
+ self.wait_and_click(xpath)
+ label = self.label_from_internal_id(slug_pk)
base = copy.deepcopy(geojsons[label]["get_polys"])
@@ -1497,24 +1466,30 @@ class SeleniumTestsContextRecords(SeleniumTests):
self.assertMap(base, slug_pk)
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(), "Unités d\'Enregistrement") or contains(text(), "Context records")]'
+ '//ul[@role="tablist"]/li/a[contains(@id, "cr-tab")][contains(@id, "operation-'
+ + str(ope_pk)
+ + '")]'
).click()
- for j in range(1, 3):
- self._test_cr(j, pks, copy.deepcopy(geojsons), method="from operation")
+ for pk, xpath in self.pks_and_details_from_table(
+ "contextrecord", "operation"
+ ):
+ slug_pk = "contextrecord-" + str(pk)
+ self._test_cr(xpath, slug_pk, copy.deepcopy(geojsons))
# from search bar
- for i in range(1, 5):
- self.access_from_dropdown('record')
- self._test_cr(i, pks, copy.deepcopy(geojsons))
+ self.access_from_dropdown("record")
+ from_table = self.pks_and_details_from_table("contextrecord")
+ for pk, xpath in from_table:
+ self.access_from_dropdown("record")
+ slug_pk = "contextrecord-" + str(pk)
+ self._test_cr(xpath, slug_pk, copy.deepcopy(geojsons))
# from bottom table, multiple displays
- for i in range(1, 4):
- self._test_cr(i, pks, copy.deepcopy(geojsons))
+ for pk, xpath in from_table:
+ slug_pk = "contextrecord-" + str(pk)
+ self._test_cr(xpath, slug_pk, copy.deepcopy(geojsons))