diff options
| author | Quentin André <quentin.andre@imt-atlantique.net> | 2021-08-19 12:15:20 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 | 
| commit | b2ea40d91efaf82ca03196bf9527383121a9edf7 (patch) | |
| tree | 04c08cca6f77aeebb5e477a93b6093d98c8f11d1 | |
| parent | 8cb3426f8d09a841fbfa476a6f6cf4e77d0bd732 (diff) | |
| download | Ishtar-b2ea40d91efaf82ca03196bf9527383121a9edf7.tar.bz2 Ishtar-b2ea40d91efaf82ca03196bf9527383121a9edf7.zip  | |
fixes previous commit
| -rw-r--r-- | archaeological_operations/tests.py | 45 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geo_items.html | 1 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_simple_map.html | 1 | ||||
| -rw-r--r-- | ishtar_common/tests.py | 59 | 
4 files changed, 54 insertions, 52 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index e2f527c79..90d74ae7d 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -4426,48 +4426,3 @@ class SeleniumTestsOperations(SeleniumTests):          self.selenium.find_element_by_xpath('//div[@class="dropdown-menu show"]/a[@href="/operation_search/"]').click()          self._test_operation(2, dic_pt, geo_elements[1], geo_elements[2]) # point based operation -    def assertPt(self, item, geom): -        self.assertEqual(item.multi_polygon.coords, geom[0].coords) -        self.assertEqual(item.point_2d.coords, geom[2].coords) - -    def assertPoly(self, item, geom, real_point=None): -        self.assertEqual(item.multi_polygon.coords, geom[0].coords) -        if real_point: -            self.assertEqual((round(item.x, 5), round(item.y, 5)), real_point.coords) -        else: -            self.assertEqual((round(item.x, 5), round(item.y, 5)), geom[1].coords) - -    def test_setUpDefaultItems(self): -        from django.contrib.gis.geos import GEOSGeometry -        from archaeological_operations.models import Operation -        base_geoms, pks = self.setUpDefaultGeoItems() -        geoms = [] -        for geom in base_geoms: -            poly = GEOSGeometry(json.dumps({'type': 'MultiPolygon', 'coordinates': geom[0]})) -            centr = GEOSGeometry(json.dumps({'type': 'Point', 'coordinates': geom[1]})) -            pt = GEOSGeometry(json.dumps({'type': 'Point', 'coordinates': geom[2]})) -            geoms.append([poly, centr, pt]) -        ope_pt = Operation.objects.get(pk=pks['Pt']) -        self.assertPt(ope_pt, geoms[0]) -        ope_poly = Operation.objects.get(pk=pks['Poly']) -        self.assertPoly(ope_poly, geoms[0]) - -        cr_poly_poly = ope_poly.context_record.get(pk=pks['CR Poly Poly']) -        self.assertPoly(cr_poly_poly, geoms[1]) -        cr_poly_pt = ope_poly.context_record.get(pk=pks['CR Poly Pt']) -        self.assertPt(cr_poly_pt, geoms[1]) -        cr_pt_poly = ope_pt.context_record.get(pk=pks['CR Pt Poly']) -        self.assertPoly(cr_pt_poly, geoms[1], geoms[0][2]) -        cr_pt_pt = ope_pt.context_record.get(pk=pks['CR Pt Pt']) -        self.assertPt(cr_pt_pt, geoms[1]) - -        self.assertPt(cr_pt_pt.base_finds.get(pk=pks['Find Point from CR Pt Pt']), geoms[2]) -        self.assertPoly(cr_pt_pt.base_finds.get(pk=pks['Find Polygon from CR Pt Pt']), geoms[2], geoms[1][2]) -        self.assertPt(cr_poly_pt.base_finds.get(pk=pks['Find Point from CR Poly Pt']), geoms[2]) -        self.assertPoly(cr_poly_pt.base_finds.get(pk=pks['Find Polygon from CR Poly Pt']), geoms[2], geoms[1][2]) -        self.assertPt(cr_pt_poly.base_finds.get(pk=pks['Find Point from CR Pt Poly']), geoms[2]) -        self.assertPoly(cr_pt_poly.base_finds.get(pk=pks['Find Polygon from CR Pt Poly']), geoms[2], geoms[0][2]) -        self.assertPt(cr_poly_poly.base_finds.get(pk=pks['Find Point from CR Poly Poly']), geoms[2]) -        self.assertPoly(cr_poly_poly.base_finds.get(pk=pks['Find Polygon from CR Poly Poly']), geoms[2]) - - diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html index 1c45b5d9f..93b9a5b35 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html @@ -1,6 +1,5 @@  {% load i18n window_field %}{% if PROFILE.mapping %}  {% if geo_item.point_2d or geo_item.multi_polygon %} -{% load ids_display_geo_items %}  <dl class="col-12">      <dt>{% trans "Display geo items" %}</dt>      <dd> diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html index a472c8b07..b77922302 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html @@ -1,6 +1,5 @@  {% if PROFILE.mapping %}  {% if geo_item.point_2d or geo_item.multi_polygon %} -{% load ids_display_geo_items %}  <div class="col-12 col-lg-6 flex-wrap">  <div class="window-map" id="map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}">  </div> diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index d8087163d..a3a2e4b5b 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -2703,6 +2703,11 @@ class IshtarBasicTest(TestCase):  class GeomaticTest(TestCase):      fixtures = FIND_FIXTURES +    def setUp(self): +        profile = models.get_current_profile() +        profile.mapping = True +        profile.save() +      def test_post_save_point(self):          class FakeGeomaticObject(object):              _meta = models.GeoItem._meta @@ -2723,10 +2728,6 @@ class GeomaticTest(TestCase):              def save(self, *args, **kwargs):                  pass -        profile = models.get_current_profile() -        profile.mapping = True -        profile.save() -          srs = models.SpatialReferenceSystem.objects.create(              label="WGS84", txt_idx="wgs84", srid=4326          ) @@ -2879,6 +2880,54 @@ class GeomaticTest(TestCase):              return geoms[0][2]          return geoms[2][1] +    def assertPt(self, item, geom): +        self.assertEqual(item.multi_polygon.coords, geom[0].coords) +        self.assertEqual(item.point_2d.coords, geom[2].coords) + +    def assertPoly(self, item, geom, real_point=None): +        self.assertEqual(item.multi_polygon.coords, geom[0].coords) +        if real_point: +            self.assertEqual((round(item.x, 5), round(item.y, 5)), real_point.coords) +        else: +            self.assertEqual((round(item.x, 5), round(item.y, 5)), geom[1].coords) + +    def test_setUpDefaultGeoItems(self): +        from django.contrib.gis.geos import GEOSGeometry +        from archaeological_operations.models import Operation +        username, password, user = create_superuser() +        base_geoms, pks = self.setUpDefaultGeoItems(user) +        geoms = [] +        for geom in base_geoms: +            poly = GEOSGeometry(json.dumps({'type': 'MultiPolygon', 'coordinates': geom[0]})) +            centr = GEOSGeometry(json.dumps({'type': 'Point', 'coordinates': geom[1]})) +            pt = GEOSGeometry(json.dumps({'type': 'Point', 'coordinates': geom[2]})) +            geoms.append([poly, centr, pt]) +        ope_pt = Operation.objects.get(pk=pks['Pt']) +        self.assertPt(ope_pt, geoms[0]) +        ope_poly = Operation.objects.get(pk=pks['Poly']) +        print(ope_poly) +        print(ope_poly.point_2d) +        self.assertPoly(ope_poly, geoms[0]) + +        cr_poly_poly = ope_poly.context_record.get(pk=pks['CR Poly Poly']) +        self.assertPoly(cr_poly_poly, geoms[1]) +        cr_poly_pt = ope_poly.context_record.get(pk=pks['CR Poly Pt']) +        self.assertPt(cr_poly_pt, geoms[1]) +        cr_pt_poly = ope_pt.context_record.get(pk=pks['CR Pt Poly']) +        self.assertPoly(cr_pt_poly, geoms[1], geoms[0][2]) +        cr_pt_pt = ope_pt.context_record.get(pk=pks['CR Pt Pt']) +        self.assertPt(cr_pt_pt, geoms[1]) + +        self.assertPt(cr_pt_pt.base_finds.get(pk=pks['Find Point from CR Pt Pt']), geoms[2]) +        self.assertPoly(cr_pt_pt.base_finds.get(pk=pks['Find Polygon from CR Pt Pt']), geoms[2], geoms[1][2]) +        self.assertPt(cr_poly_pt.base_finds.get(pk=pks['Find Point from CR Poly Pt']), geoms[2]) +        self.assertPoly(cr_poly_pt.base_finds.get(pk=pks['Find Polygon from CR Poly Pt']), geoms[2], geoms[1][2]) +        self.assertPt(cr_pt_poly.base_finds.get(pk=pks['Find Point from CR Pt Poly']), geoms[2]) +        self.assertPoly(cr_pt_poly.base_finds.get(pk=pks['Find Polygon from CR Pt Poly']), geoms[2], geoms[0][2]) +        self.assertPt(cr_poly_poly.base_finds.get(pk=pks['Find Point from CR Poly Poly']), geoms[2]) +        self.assertPoly(cr_poly_poly.base_finds.get(pk=pks['Find Polygon from CR Poly Poly']), geoms[2]) + +  class NewItems(TestCase):      fixtures = COMMON_FIXTURES @@ -3405,7 +3454,7 @@ class SeleniumTests(StaticLiveServerTestCase):              element)      def assertMap(self, dic_base, features_collecs=None): -        mapdiv = self.selenium.find_element_by_class_name("window-map") +        mapdiv = self.selenium.find_element_by_id("window-map")          mapid = mapdiv.get_attribute("id")          id = int(re.search(r'\d+$', mapid).group())          # TODO: use the map and not the map_features in the js function  | 
