summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/tests.py157
1 files changed, 80 insertions, 77 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index a71706e40..16bf6d303 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -26,6 +26,7 @@ from django.conf import settings
from django.contrib.auth.models import Permission
from django.core.exceptions import ValidationError, ImproperlyConfigured
from django.core.urlresolvers import reverse
+from django.test import tag
from django.test.client import Client
from django.utils.translation import pgettext_lazy
@@ -1364,89 +1365,91 @@ class GraphGenerationTest(ContextRecordInit, TestCase):
self.assertNotIn('"CR 2D"', content)
+@tag('ui')
class SeleniumTestsContextRecords(SeleniumTests):
fixtures = CONTEXT_RECORD_FIXTURES
+ def _test_cr(self, i, dic_polygon, dic_point, geom_bf):
+ cr_label = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td[2]').text
+ if cr_label[3:5] == "Pt":
+ dic_base = dic_point
+ else:
+ dic_base = dic_polygon
+ cr = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td/a[@class="display_details"]')
+ self.scroll(cr)
+ cr.click()
+ self.WebDriverWait(self.selenium, 2).until(
+ lambda driver: driver.find_element_by_xpath(
+ '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]'))
+ self.selenium.find_element_by_xpath(
+ '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]')
+ dd = '//dl[@class="col-12"]/dd'
+ self.selenium.find_element_by_xpath(dd + '/label[text()="Display associated features: "]')
+ select = dd + '/select[@name="display-geo-items"]'
+ disp = self.selenium.find_element_by_xpath(select)
+ self.assertEqual(disp.get_attribute("value"), "")
+ self.assertMap(dic_base)
+
+ # context record specific
+
+ # click on "Base finds"
+ self.selenium.execute_script('return initialize_test_map()')
+ self.scroll(disp)
+ disp.click()
+ self.selenium.find_element_by_xpath(select + '/option[@value="basefinds"]').click()
+ cr_geoms = [
+ {'type': 'FeatureCollection',
+ 'features': [
+ {'geometry':
+ {'coordinates': geom_bf[0],
+ 'type': 'MultiPolygon'},
+ 'properties': {'label': 'Find 1 from ' + cr_label},
+ 'type': 'Feature'},
+ {'geometry': {'coordinates': geom_bf[0],
+ 'type': 'MultiPolygon'},
+ 'properties': {'label': 'Find 2 from ' + cr_label},
+ 'type': 'Feature'}]
+ }
+ ]
+ self.assertMap(dic_base, cr_geoms)
+
+ select_get_poly = dd + '/select[@name="get-polygons"]'
+ get_poly = self.selenium.find_element_by_xpath(select_get_poly)
+ self.selenium.execute_script('return initialize_test_map()')
+ get_poly.click()
+ self.selenium.find_element_by_xpath(select_get_poly + '/option[@value="points"]').click()
+ cr_geoms = [
+ {'type': 'FeatureCollection',
+ 'features': [
+ {'geometry':
+ {'coordinates': geom_bf[1],
+ 'type': 'Point'},
+ 'properties': {'label': 'Find 1 from ' + cr_label},
+ 'type': 'Feature'},
+ {'geometry': {'coordinates': geom_bf[2],
+ 'type': 'Point'},
+ 'properties': {'label': 'Find 2 from ' + cr_label},
+ 'type': 'Feature'}]
+ }
+ ]
+ self.assertMap(dic_base, cr_geoms)
+
+ # Click on "None"
+ self.selenium.execute_script('return initialize_test_map()')
+ disp.click()
+ self.selenium.find_element_by_xpath(select + '/option[@value=""]').click()
+ self.assertMap(dic_base)
+
def test_geo_items(self):
- def test_cr(i):
- cr_label = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td[2]').text
- if cr_label[3:5] == "Pt":
- dic_base = dic_point
- else:
- dic_base = dic_polygon
- cr = self.selenium.find_element_by_xpath('//tbody/tr[' + str(i) + ']/td/a[@class="display_details"]')
- self.scroll(cr)
- cr.click()
- self.WebDriverWait(self.selenium, 2).until(
- lambda driver: driver.find_element_by_xpath(
- '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]'))
- self.selenium.find_element_by_xpath(
- '//dl[@class="col-12"]/dt[text()="Display geo items" or text()="Afficher les éléments"]')
- dd = '//dl[@class="col-12"]/dd'
- self.selenium.find_element_by_xpath(dd + '/label[text()="Display associated features: "]')
- select = dd + '/select[@name="display-geo-items"]'
- disp = self.selenium.find_element_by_xpath(select)
- self.assertEqual(disp.get_attribute("value"), "")
- self.assertMap(dic_base)
-
- # context record specific
-
- # click on "Base finds"
- self.selenium.execute_script('return initialize_test_map()')
- self.scroll(disp)
- disp.click()
- self.selenium.find_element_by_xpath(select + '/option[@value="basefinds"]').click()
- cr_geoms = [
- {'type': 'FeatureCollection',
- 'features': [
- {'geometry':
- {'coordinates': [[[[1, 1], [5, 1], [5, 5], [1, 5], [1, 1]], [[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]], [[[6, 3], [9, 2], [9, 4], [6, 3]]]],
- 'type': 'MultiPolygon'},
- 'properties': {'label': 'Find 1 from ' + cr_label},
- 'type': 'Feature'},
- {'geometry': {'coordinates': [],
- 'type': 'MultiPolygon'},
- 'properties': {'label': 'Find 2 from ' + cr_label},
- 'type': 'Feature'}]
- }
- ]
- self.assertMap(dic_base, cr_geoms)
-
- select_get_poly = dd + '/select[@name="get-polygons"]'
- get_poly = self.selenium.find_element_by_xpath(select_get_poly)
- self.selenium.execute_script('return initialize_test_map()')
- get_poly.click()
- self.selenium.find_element_by_xpath(select_get_poly + '/option[@value="points"]').click()
- cr_geoms = [
- {'type': 'FeatureCollection',
- 'features': [
- {'geometry':
- {'coordinates': [3.861, 3.028],
- 'type': 'Point'},
- 'properties': {'label': 'Find 1 from ' + cr_label},
- 'type': 'Feature'},
- {'geometry': {'coordinates': [2, 43],
- 'type': 'Point'},
- 'properties': {'label': 'Find 2 from ' + cr_label},
- 'type': 'Feature'}]
- }
- ]
- self.assertMap(dic_base, cr_geoms)
-
- # Click on "None"
- self.selenium.execute_script('return initialize_test_map()')
- disp.click()
- self.selenium.find_element_by_xpath(select + '/option[@value=""]').click()
- self.assertMap(dic_base)
-
- self.setUpDefaultGeoItems()
+ geo_elements = self.setUpDefaultGeoItems()
+ poly_cr, centr_cr, pt_cr = geo_elements[1]
dic_polygon = {
'type': 'FeatureCollection',
'features': [
{'geometry':
- {'coordinates': [[[[1,1],[5,1],[5,5],[1,5],[1,1]],[[2,2],[2,3],[3,3],[3,2],[2,2]]],[[[6,3],[9,2],[9,4],[6,3]]]],
- 'type': 'MultiPolygon'},
+ {'coordinates': poly_cr,
+ 'type': 'MultiPolygon'},
'properties': {},
'type': 'Feature'}
]}
@@ -1454,14 +1457,14 @@ class SeleniumTestsContextRecords(SeleniumTests):
'type': 'FeatureCollection',
'features': [
{'geometry':
- {'coordinates': [2,43],
+ {'coordinates': pt_cr,
'type': 'Point'},
'properties': {},
'type': 'Feature'}
]}
for i in range(1, 5):
- dropdown = self.selenium.find_element_by_xpath('//a[@class="nav-link dropdown-toggle"]')
+ dropdown = self.selenium.find_element_by_xpath('//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]')
self.scroll(dropdown)
dropdown.click()
self.selenium.find_element_by_xpath('//div[@class="dropdown-menu show"]/a[@href="/record_search/"]').click()
- test_cr(i) \ No newline at end of file
+ self._test_cr(i, dic_polygon, dic_point, geo_elements[2]) \ No newline at end of file