diff options
| -rw-r--r-- | archaeological_finds/tests.py | 6 | ||||
| -rw-r--r-- | archaeological_operations/tests.py | 67 | ||||
| -rw-r--r-- | ishtar_common/tests.py | 20 | 
3 files changed, 30 insertions, 63 deletions
| diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 688699d3e..955b1aedc 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -2539,7 +2539,7 @@ class GeomaticTest(FindInit, TestCase):          point_2d_bf = GEOSGeometry("POINT({} {})".format(3.9, 2.9), srid=4326)          xy_bf = 3.9, 2.9 -        pks = {'cr': {}, 'bf': {}} +        pks = {}          ope.multi_polygon = "SRID=4326;" + poly_ope          ope.multi_polygon_source = "P" @@ -2574,7 +2574,7 @@ class GeomaticTest(FindInit, TestCase):              cr.point_2d = point_2d_cr          cr.save()          cr = ContextRecord.objects.get(pk=cr.pk) -        pks['cr'][label_cr] = cr.pk +        pks[label_cr] = cr.pk          bfs = []          for bf_geom in list_geom_bf: @@ -2596,7 +2596,7 @@ class GeomaticTest(FindInit, TestCase):              bf.save()              bf = models.BaseFind.objects.get(pk=bf.pk)              bfs.append(bf) -            pks['bf'][default['label']] = bf.pk +            pks[default['label']] = bf.pk              find = models.Find.objects.create()              find.base_finds.add(bf) diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 1ab511458..e2f527c79 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -4427,72 +4427,47 @@ class SeleniumTestsOperations(SeleniumTests):          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) -        print(item, " multi_poly:") -        print(item.multi_polygon.coords) -        print("geom:") -        print(geom[0].coords) -        print('result: ', item.multi_polygon.coords == geom[0].coords) -        print("point_2d:") -        print((round(item.x, 5), round(item.y, 5))) -        print("geom:") -        print(geom[2].coords) -        print('result: ', (round(item.x, 5), round(item.y, 5)) == geom[2].coords) -        print('\n') +        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)), geom[1].coords) -        # else: -        #   self.assertEqual((round(item.x, 5), round(item.y, 5)), real_point.coords) -        print(item, " multi_poly:") -        print(item.multi_polygon.coords) -        print("geom:") -        print(geom[0].coords) -        print('result: ', item.multi_polygon.coords==geom[0].coords) -        print("point_2d:") -        print((round(item.x, 5), round(item.y, 5))) -        print("geom:") -        point = geom[1].coords +        self.assertEqual(item.multi_polygon.coords, geom[0].coords)          if real_point: -            point = real_point.coords -        print(point) -        print('result: ', (round(item.x, 5), round(item.y, 5)) == point) -        print('\n') +            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, ope_pks = self.setUpDefaultGeoItems() +        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=ope_pks[0]) +        ope_pt = Operation.objects.get(pk=pks['Pt'])          self.assertPt(ope_pt, geoms[0]) -        ope_poly = Operation.objects.get(pk=ope_pks[1]) +        ope_poly = Operation.objects.get(pk=pks['Poly'])          self.assertPoly(ope_poly, geoms[0]) -        cr_poly_poly = ope_poly.context_record.all()[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.all()[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.all()[0] +        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.all()[1] +        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.all()[0], geoms[2]) -        self.assertPoly(cr_pt_pt.base_finds.all()[1], geoms[2], geoms[1][2]) -        self.assertPt(cr_poly_pt.base_finds.all()[0], geoms[2]) -        self.assertPoly(cr_poly_pt.base_finds.all()[1], geoms[2], geoms[1][2]) -        self.assertPt(cr_pt_poly.base_finds.all()[0], geoms[2]) -        self.assertPoly(cr_pt_poly.base_finds.all()[1], geoms[2], geoms[0][2]) -        self.assertPt(cr_poly_poly.base_finds.all()[0], geoms[2]) -        self.assertPoly(cr_poly_poly.base_finds.all()[1], geoms[2]) +        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/tests.py b/ishtar_common/tests.py index ced35a672..bebb58eac 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3256,20 +3256,12 @@ class SeleniumTests(StaticLiveServerTestCase):          ope1 = create_operation(self.user)          ope2 = create_operation(self.user) -        pks = {'ope': {'Pt': ope1.pk, 'Poly': ope2.pk}, 'cr': {}, 'bf': {}} +        pks = {'Pt': ope1.pk, 'Poly': ope2.pk} -        def merge_pks(dic1, dic2): -            for key in dic2.keys(): -                for label in dic2[key]: -                    dic1[key][label] = dic2[key][label] - -        merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Point", ["Polygon", "Point"], "CR Pt Pt")) -        merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Polygon", ["Polygon", "Point"], "CR Pt Poly")) -        merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Point", ["Polygon", "Point"], "CR Poly Pt")) -        merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Polygon", ["Polygon", "Point"], "CR Poly Poly")) - -        print('PKS AAAAAAAAAAAAAAAAA') -        print(pks) +        pks.update(GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Point", ["Polygon", "Point"], "CR Pt Pt")) +        pks.update(GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Polygon", ["Polygon", "Point"], "CR Pt Poly")) +        pks.update(GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Point", ["Polygon", "Point"], "CR Poly Pt")) +        pks.update(GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Polygon", ["Polygon", "Point"], "CR Poly Poly"))          geom_ope = [              [[[[1, 1], [5, 1], [5, 5], [1, 5], [1, 1]], [[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]], @@ -3289,7 +3281,7 @@ class SeleniumTests(StaticLiveServerTestCase):              [4.42105, 2.73684],              [3.9, 2.9]          ] -        return [geom_ope, geom_cr, geom_bf], [ope1.pk, ope2.pk] +        return [geom_ope, geom_cr, geom_bf], pks      def scroll(self, element): | 
