diff options
Diffstat (limited to 'archaeological_finds/tests.py')
| -rw-r--r-- | archaeological_finds/tests.py | 599 | 
1 files changed, 146 insertions, 453 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 955b1aedc..00e14307c 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -2520,466 +2520,159 @@ class GeomaticTest(FindInit, TestCase):          self.assertEqual(base_find.point_2d.ewkt, "SRID=4326;POINT (42 3)")          self.assertEqual(base_find.point_source, "P") -    @staticmethod -    def create_cr_with_bfs(ope, geom_ope, geom_cr, list_geom_bf, label_cr): -        wgs84 = SpatialReferenceSystem.objects.get(srid=4326) -        poly_ope = ("MULTIPOLYGON(((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)))") -        point_ope = GEOSGeometry("POINT({} {} {})".format(3.8, 3, 1), srid=4326) -        point_2d_ope = GEOSGeometry("POINT({} {})".format(3.8, 3), srid=4326) -        xy_ope = 3.8, 3 -        poly_cr = ("MULTIPOLYGON(((2 1,5 1,5 5,1 5,2 1),(2 2,2 3,3 3,3 2,2 2))," -                   "((6 3,9 2,9 4,6 3)))") -        point_cr = GEOSGeometry("POINT({} {} {})".format(3.9, 3, 1), srid=4326) -        point_2d_cr = GEOSGeometry("POINT({} {})".format(3.9, 3), srid=4326) -        xy_cr = 3.9, 3 -        poly_bf = ("MULTIPOLYGON(((2 1,4 1,4 4,1 4,2 1),(2 2,2 3,3 3,3 2,2 2))," -                    "((6 3,9 2,9 4,6 3)))") -        point_bf = GEOSGeometry("POINT({} {} {})".format(3.9, 2.9, 1), srid=4326) -        point_2d_bf = GEOSGeometry("POINT({} {})".format(3.9, 2.9), srid=4326) -        xy_bf = 3.9, 2.9 - -        pks = {} - -        ope.multi_polygon = "SRID=4326;" + poly_ope -        ope.multi_polygon_source = "P" -        ope.multi_polygon_source_item = str(ope._meta.verbose_name) -        ope.spatial_reference_system = wgs84 -        if geom_ope == "Point": -            ope.point = point_ope -            ope.point_source = "P" -            ope.point_source_item = str(ope._meta.verbose_name) -            ope.x, ope.y = xy_ope -            ope.point_2d = point_2d_ope -        ope.save()  # needs 2 saves because point_2d is none for multi_polygon -        ope = Operation.objects.get(pk=ope.pk) -        ope.save() -        ope = Operation.objects.get(pk=ope.pk) - -        default = { -            "label": label_cr, -            "operation": ope, -        } -        cr = ContextRecord.objects.create(**default) -        cr = ContextRecord.objects.get(pk=cr.pk) -        cr.multi_polygon = "SRID=4326;" + poly_cr -        cr.multi_polygon_source = "P" -        cr.multi_polygon_source_item = str(cr._meta.verbose_name) -        cr.spatial_reference_system = wgs84 -        if geom_cr == "Point": -            cr.point = point_cr -            cr.point_source = "P" -            cr.point_source_item = str(cr._meta.verbose_name) -            cr.x, cr.y = xy_cr -            cr.point_2d = point_2d_cr -        cr.save() -        cr = ContextRecord.objects.get(pk=cr.pk) -        pks[label_cr] = cr.pk - -        bfs = [] -        for bf_geom in list_geom_bf: -            default = { -                "label": "Find " + bf_geom + " from " + label_cr, -                "context_record": cr, -            } -            bf = models.BaseFind.objects.create(**default) -            bf.multi_polygon = "SRID=4326;" + poly_bf -            bf.multi_polygon_source = "P" -            bf.multi_polygon_source_item = str(bf._meta.verbose_name) -            bf.spatial_reference_system = wgs84 -            if bf_geom == "Point": -                bf.point = point_bf -                bf.point_source = "P" -                bf.point_source_item = str(bf._meta.verbose_name) -                bf.x, bf.y = xy_bf -                bf.point_2d = point_2d_bf -            bf.save() -            bf = models.BaseFind.objects.get(pk=bf.pk) -            bfs.append(bf) -            pks[default['label']] = bf.pk - -            find = models.Find.objects.create() -            find.base_finds.add(bf) -            find.save() -        return pks -      def test_get_geo_items(self): -        wgs84 = SpatialReferenceSystem.objects.get(srid=4326) +        from archaeological_operations.models import Operation +        from archaeological_context_records.models import ContextRecord +        from archaeological_finds.models import BaseFind +        from ishtar_common.tests import GeomaticTest as BaseGeomaticTest + +        #profile = models.get_current_profile()          profile = get_current_profile()          profile.mapping = True          profile.save() -        base_find = models.BaseFind.objects.all()[0] -        context_record = ContextRecord.objects.get(pk=base_find.context_record.pk) -        operation = self.create_operation()[0] -        ope = self.create_operation()[1] -        limit = ( -            "MULTIPOLYGON(((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)))" -        ) -        geom = GEOSGeometry("POINT({} {} {})".format(2, 43, 1), srid=4326) -        geom_2d = GEOSGeometry("POINT({} {})".format(2, 43), srid=4326) -        xy = 2, 43 -        geom_params = [limit, geom, geom_2d, xy, wgs84] - -        # with point -        cr_pt_pt, bfs = self.create_cr_with_bfs(operation, "Point", "Point", ["Point"], "CR Pt Pt", geom_params) -        base_find_pt = bfs[0] - -        dic_pt_t = { -            "type": "Feature", -            "geometry": {"type": "MultiPolygon", "coordinates": []}, -            "properties": {"label": "Find 1 from CR Pt Pt"}, -        } -        res = base_find_pt.get_geo_items(get_polygons=True) -        self.assertEqual(dic_pt_t, res) -        dic_pt_f = copy.deepcopy(dic_pt_t) -        dic_pt_f["geometry"] = {"type": "Point", "coordinates": [2.0, 43.0]} -        res = base_find_pt.get_geo_items(get_polygons=False) -        self.assertEqual(dic_pt_f, res) - -        # test API with point -        url_pts = reverse("api-get-geo-points") -        url_polys = reverse("api-get-geo-polygons") -        response = self.client.get(url_pts + "?pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_pts + "?pk=" + str(base_find_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertIn(json.dumps(dic_pt_f).encode("utf-8"), response.content) - -        # test context record with point as base find -        dic_pt_f_copy = copy.deepcopy(dic_pt_f) -        dic_pt_pt_f = copy.deepcopy(dic_pt_f) -        dic_pt_pt_f["properties"] = { -            "label": "CR Pt Pt", -            "base-finds": {"type": "FeatureCollection", "features": [dic_pt_f_copy]}, -        } -        self.assertEqual(dic_pt_pt_f, cr_pt_pt.get_geo_items(False)) - -        dic_pt_t_copy = copy.deepcopy(dic_pt_t) -        dic_pt_pt_t = { -            "type": "Feature", -            "geometry": {"type": "MultiPolygon", "coordinates": []}, -            "properties": { -                "label": "CR Pt Pt", -                "base-finds": { -                    "type": "FeatureCollection", -                    "features": [dic_pt_t_copy], -                }, -            }, -        } -        self.assertEqual(dic_pt_pt_t, cr_pt_pt.get_geo_items(True)) - -        # test of API for point context record with point as base find -        response = self.client.get(url_pts + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_pts + "?context_record_pk=" + str(cr_pt_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertIn(json.dumps(dic_pt_pt_f).encode("utf-8"), response.content) - -        response = self.client.get(url_polys + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_polys + "?context_record_pk=" + str(cr_pt_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertIn(json.dumps(dic_pt_pt_t).encode("utf-8"), response.content) - -        # the context record is a multi-polygon -        cr_poly_pt, bfs = self.create_cr_with_bfs( -            operation, "Polygon", ["Point"], "CR Poly Pt", geom_params -        ) -        base_find_pt = bfs[0] -        dic_poly_t = { -            "type": "Feature", -            "geometry": { -                "type": "MultiPolygon", -                "coordinates": [ -                    [ -                        [[1.0, 1.0], [5.0, 1.0], [5.0, 5.0], [1.0, 5.0], [1.0, 1.0]], -                        [[2.0, 2.0], [2.0, 3.0], [3.0, 3.0], [3.0, 2.0], [2.0, 2.0]], -                    ], -                    [[[6.0, 3.0], [9.0, 2.0], [9.0, 4.0], [6.0, 3.0]]], -                ], -            }, -            "properties": {"label": "Find 1 from CR Poly Pt"}, -        } - -        dic_poly_pt_t = copy.deepcopy(dic_poly_t) -        dic_pt_t_from_poly = copy.deepcopy(dic_pt_t_copy) -        dic_pt_t_from_poly["properties"]["label"] = "Find 1 from CR Poly Pt" -        dic_poly_pt_t["properties"] = { -            "label": "CR Poly Pt", -            "base-finds": { -                "type": "FeatureCollection", -                "features": [dic_pt_t_from_poly], -            }, -        } -        self.assertEqual(dic_poly_pt_t, cr_poly_pt.get_geo_items(True)) - -        dic_poly_f = { -            "type": "Feature", -            "geometry": {"type": "Point", "coordinates": [3.86111, 3.02778]}, -            "properties": {"label": "Find 1 from CR Poly Pt"}, -        } -        dic_pt_f_from_poly = copy.deepcopy(dic_pt_f) -        dic_pt_f_from_poly["properties"]["label"] = "Find 1 from CR Poly Pt" -        dic_poly_pt_f = copy.deepcopy(dic_poly_f) -        dic_poly_pt_f["properties"] = { -            "label": "CR Poly Pt", -            "base-finds": { -                "type": "FeatureCollection", -                "features": [dic_pt_f_from_poly], -            }, -        } -        self.assertEqual(dic_poly_pt_f, cr_poly_pt.get_geo_items(False)) - -        # test of API for point context record with multipolygon as base find -        response = self.client.get(url_pts + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_pts + "?context_record_pk=" + str(cr_poly_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertIn(json.dumps(dic_poly_pt_f).encode("utf-8"), response.content) - -        response = self.client.get(url_polys + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get( -            url_polys + "?context_record_pk=" + str(cr_poly_pt.pk) -        ) -        self.assertEqual(response.status_code, 200) -        self.assertIn(json.dumps(dic_poly_pt_t).encode("utf-8"), response.content) - -        # we add a base find which is a multi-polygon -        cr_poly_poly_and_pt, bfs = self.create_cr_with_bfs( -            ope, "Polygon", ["Polygon", "Point"], "CR Poly Poly Pt", geom_params -        ) -        base_find_poly, base_find_pt = bfs - -        dic_poly_t_from_poly = copy.deepcopy(dic_poly_t) -        dic_poly_t_from_poly["properties"]["label"] = "Find 1 from CR Poly Poly Pt" -        dic_poly_f_from_poly = copy.deepcopy(dic_poly_f) -        dic_poly_f_from_poly["properties"]["label"] = "Find 1 from CR Poly Poly Pt" - -        res_poly = base_find_poly.get_geo_items(get_polygons=True) -        self.assertEqual(dic_poly_t_from_poly, res_poly) -        res_centroid = base_find_poly.get_geo_items(get_polygons=False) -        self.assertEqual(dic_poly_f_from_poly, res_centroid) +        '''username, password, user = create_superuser() +        client = Client() +        client.login(username=username, password=password) +        print("is_authenticated") +        print(user.is_authenticated())''' -        # test API with polygon -        response = self.client.get(url_polys + "?pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_polys + "?pk=" + str(base_find_poly.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_poly_t_from_poly, json.loads(response.content)) -        response = self.client.get(url_pts + "?pk=" + str(base_find_poly.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_poly_f_from_poly, json.loads(response.content)) +        geoms, pks = BaseGeomaticTest.setUpDefaultGeoItems(self.user) -        # context record is a polygon -        # (and one base find is a point and the other is a polygon) -        self.assertEqual( -            base_find_pt.context_record.pk, base_find_poly.context_record.pk -        ) -        dic_poly_t_both = copy.deepcopy(dic_poly_t_from_poly) -        dic_poly_t_both["properties"]["label"] = "Find 1 from CR Poly Poly Pt" -        dic_poly_f_both = copy.deepcopy(dic_poly_f_from_poly) -        dic_poly_f_both["properties"]["label"] = "Find 1 from CR Poly Poly Pt" -        dic_pt_t_both = copy.deepcopy(dic_pt_t_from_poly) -        dic_pt_t_both["properties"]["label"] = "Find 2 from CR Poly Poly Pt" -        dic_pt_f_both = copy.deepcopy(dic_pt_f_from_poly) -        dic_pt_f_both["properties"]["label"] = "Find 2 from CR Poly Poly Pt" - -        dic_poly_poly_and_pt_t = copy.deepcopy(dic_poly_t) -        dic_poly_poly_and_pt_t["properties"] = { -            "label": "CR Poly Poly Pt", -            "base-finds": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_t_both, -                    dic_pt_t_both, -                ], -            }, -        } -        self.assertEqual( -            dic_poly_poly_and_pt_t, cr_poly_poly_and_pt.get_geo_items(True) -        ) - -        dic_poly_poly_and_pt_f = copy.deepcopy(dic_poly_f) -        dic_poly_poly_and_pt_f["properties"] = { -            "base-finds": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_f_both, -                    dic_pt_f_both, -                ], -            }, -            "label": "CR Poly Poly Pt", -        } -        self.assertEqual( -            dic_poly_poly_and_pt_f, cr_poly_poly_and_pt.get_geo_items(False) -        ) - -        # test of API for multipolygon context record with a multipolygon and a point as base find -        response = self.client.get(url_pts + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get( -            url_pts + "?context_record_pk=" + str(cr_poly_poly_and_pt.pk) -        ) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_poly_poly_and_pt_f, json.loads(response.content)) - -        response = self.client.get(url_polys + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get( -            url_polys + "?context_record_pk=" + str(cr_poly_poly_and_pt.pk) -        ) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_poly_poly_and_pt_t, json.loads(response.content)) - -        # context record is a point, base find 1 a polygon and base find 2 a point -        cr_pt_poly_and_pt, bfs = self.create_cr_with_bfs( -            ope, "Point", ["Polygon", "Point"], "CR Pt Poly Pt", geom_params -        ) -        base_find_poly, base_find_pt = bfs - -        dic_poly_t_pt_based = copy.deepcopy(dic_poly_t_from_poly) -        dic_poly_t_pt_based["properties"]["label"] = "Find 1 from CR Pt Poly Pt" -        dic_poly_f_pt_based = copy.deepcopy(dic_poly_f_from_poly) -        dic_poly_f_pt_based["properties"]["label"] = "Find 1 from CR Pt Poly Pt" -        dic_pt_t_pt_based = copy.deepcopy(dic_pt_t_from_poly) -        dic_pt_t_pt_based["properties"]["label"] = "Find 2 from CR Pt Poly Pt" -        dic_pt_f_pt_based = copy.deepcopy(dic_pt_f_from_poly) -        dic_pt_f_pt_based["properties"]["label"] = "Find 2 from CR Pt Poly Pt" - -        dic_pt_poly_and_pt_t = copy.deepcopy(dic_pt_pt_t) -        dic_pt_poly_and_pt_t["properties"] = { -            "base-finds": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_t_pt_based, -                    dic_pt_t_pt_based, -                ], -            }, -            "label": "CR Pt Poly Pt", -        } -        self.assertEqual(dic_pt_poly_and_pt_t, cr_pt_poly_and_pt.get_geo_items(True)) - -        dic_pt_poly_and_pt_f = copy.deepcopy(dic_pt_pt_f) -        dic_pt_poly_and_pt_f["properties"] = { -            "base-finds": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_f_pt_based, -                    dic_pt_f_pt_based, -                ], -            }, -            "label": "CR Pt Poly Pt", -        } -        self.assertEqual(dic_pt_poly_and_pt_f, cr_pt_poly_and_pt.get_geo_items(False)) - -        # test of API for point context record with multipolygon as base find -        response = self.client.get(url_pts + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get( -            url_pts + "?context_record_pk=" + str(cr_pt_poly_and_pt.pk) -        ) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_pt_poly_and_pt_f, json.loads(response.content)) - -        response = self.client.get(url_polys + "?context_record_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get( -            url_polys + "?context_record_pk=" + str(cr_pt_poly_and_pt.pk) -        ) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_pt_poly_and_pt_t, json.loads(response.content)) - -        # test of operation - -        dic_pt_pt_and_poly_pt_and_poly_f = copy.deepcopy(dic_pt_f) -        dic_pt_pt_and_poly_pt_and_poly_f["properties"] = { -            "label": "OA2", -            "context-records": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_poly_and_pt_f, -                    dic_pt_poly_and_pt_f, -                ], -            }, -        } -        dic_pt_pt_and_poly_pt_and_poly_t = copy.deepcopy(dic_pt_t) -        dic_pt_pt_and_poly_pt_and_poly_t["properties"] = { -            "context-records": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_poly_and_pt_t, -                    dic_pt_poly_and_pt_t, -                ], -            }, -            "label": "OA2", -        } -        dic_poly_pt_and_poly_pt_and_poly_t = copy.deepcopy(dic_poly_t) -        dic_poly_pt_and_poly_pt_and_poly_t["properties"] = { -            "context-records": { -                "type": "FeatureCollection", -                "features": [ -                    dic_poly_poly_and_pt_t, -                    dic_pt_poly_and_pt_t, -                ], -            }, -            "label": "OA2", -        } - -        ope_pt = Operation.objects.get(pk=ope.pk) -        ope_pt.point = geom -        ope_pt.multi_polygon = None -        ope_pt.multi_polygon_source = None -        ope_pt.multi_polygon_source_item = None -        ope_pt.x, ope_pt.y = xy -        ope_pt.point_2d = geom_2d -        ope_pt.spatial_reference_system = wgs84 -        ope_pt.save() -        ope_pt = Operation.objects.get(pk=ope_pt.pk) -        self.assertEqual(dic_pt_pt_and_poly_pt_and_poly_f, ope_pt.get_geo_items(False)) -        self.assertEqual(dic_pt_pt_and_poly_pt_and_poly_t, ope_pt.get_geo_items(True)) - -        response = self.client.get(url_polys + "?operation_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_polys + "?operation_pk=" + str(ope_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_pt_pt_and_poly_pt_and_poly_t, json.loads(response.content)) - -        response = self.client.get(url_pts + "?operation_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_pts + "?operation_pk=" + str(ope_pt.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual(dic_pt_pt_and_poly_pt_and_poly_f, json.loads(response.content)) - -        # ope is now a multipolygon -        ope_poly = Operation.objects.get(pk=ope.pk) -        ope_poly.multi_polygon = "SRID=4326;" + limit -        ope_poly.save() -        ope_poly = Operation.objects.get(pk=ope_poly.pk) - -        self.assertEqual( -            dic_pt_pt_and_poly_pt_and_poly_f, ope_poly.get_geo_items(False) -        ) -        self.assertEqual( -            dic_poly_pt_and_poly_pt_and_poly_t, ope_poly.get_geo_items(True) -        ) +        url_pts = reverse("api-get-geo-points") +        url_polys = reverse("api-get-geo-polygons") -        response = self.client.get(url_polys + "?operation_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_polys + "?operation_pk=" + str(ope_poly.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual( -            dic_poly_pt_and_poly_pt_and_poly_t, json.loads(response.content) -        ) +        cache_dics_t, cache_dics_f = {}, {} -        response = self.client.get(url_pts + "?operation_pk=0") -        self.assertEqual(response.status_code, 404) -        response = self.client.get(url_pts + "?operation_pk=" + str(ope_poly.pk)) -        self.assertEqual(response.status_code, 200) -        self.assertEqual( -            dic_pt_pt_and_poly_pt_and_poly_f, json.loads(response.content) -        ) +        def finds_first(x): +            if x[:2] == "CR": +                return 0 +            if x[:4] == "Find": +                return -1 +            else: +                return 1 + +        labels = list(pks.keys()) +        labels.sort(key=finds_first) +        for label in labels: +            pk = pks[label] +            if label[:4] == "Find": +                dic_t = { +                    "type": "Feature", +                    "geometry": { +                        "type": "MultiPolygon", "coordinates": geoms[2][0] +                    }, +                    "properties": {"label": label}, +                } +                dic_f = { +                    "type": "Feature", +                    "geometry": { +                        "type": "Point", "coordinates": BaseGeomaticTest.pt_coords_from_label(label, geoms), +                    }, +                    "properties": {"label": label}, +                } +                cache_dics_t[label] = dic_t +                cache_dics_f[label] = dic_f +                res_t = BaseFind.objects.get(pk=pk).get_geo_items(get_polygons=True) +                res_f = BaseFind.objects.get(pk=pk).get_geo_items(get_polygons=False) +                get_pk = "?pk=" + +            elif label[:2] == "CR": +                cache_key = lambda x: "Find " + x + " from " + label +                dic_t = { +                    "type": "Feature", +                    "geometry": { +                        "type": "MultiPolygon", "coordinates": geoms[1][0] +                    }, +                    "properties": { +                        "label": label, +                        "base-finds": { +                            'type': 'FeatureCollection', +                            'features': [ +                                cache_dics_t[cache_key("Polygon")], +                                cache_dics_t[cache_key("Point")], +                            ] +                        } +                    }, +                } +                dic_f = { +                    "type": "Feature", +                    "geometry": { +                        "type": "Point", "coordinates": BaseGeomaticTest.pt_coords_from_label(label, geoms), +                    }, +                    "properties": { +                        "label": label, +                        "base-finds": { +                            'type': 'FeatureCollection', +                            'features': [ +                                cache_dics_f[cache_key("Polygon")], +                                cache_dics_f[cache_key("Point")], +                            ] +                        } +                    }, +                } +                cache_dics_t[label] = dic_t +                cache_dics_f[label] = dic_f +                res_t = ContextRecord.objects.get(pk=pk).get_geo_items(get_polygons=True) +                res_f = ContextRecord.objects.get(pk=pk).get_geo_items(get_polygons=False) +                get_pk = "?context_record_pk=" +            else: +                real_label = "OA3" +                cache_key_prefix = "CR " + label + " " +                if label == "Pt": +                    real_label = "OA2" +                dic_t = { +                    "type": "Feature", +                    "geometry": { +                        "type": "MultiPolygon", "coordinates": geoms[0][0] +                    }, +                    "properties": { +                        "label": real_label, +                        "context-records": { +                            'type': 'FeatureCollection', +                            'features': [ +                                cache_dics_t[cache_key_prefix + "Poly"], +                                cache_dics_t[cache_key_prefix + "Pt"], +                            ] +                        } +                    }, +                } +                dic_f = { +                    "type": "Feature", +                    "geometry": { +                        "type": "Point", "coordinates": BaseGeomaticTest.pt_coords_from_label(label, geoms), +                    }, +                    "properties": { +                        "label": real_label, +                        "context-records": { +                            'type': 'FeatureCollection', +                            'features': [ +                                cache_dics_f[cache_key_prefix + "Poly"], +                                cache_dics_f[cache_key_prefix + "Pt"], +                            ] +                        } +                    }, +                } +                res_t = Operation.objects.get(pk=pk).get_geo_items(get_polygons=True) +                res_f = Operation.objects.get(pk=pk).get_geo_items(get_polygons=False) +                get_pk = "?operation_pk=" + +            self.assertEqual(res_t, dic_t) +            print("url") +            print(url_polys + get_pk + "0") +            response = self.client.get(url_polys + get_pk + "0") +            print('response') +            print(response) +            self.assertEqual(response.status_code, 404) +            response = self.client.get(url_polys + get_pk + str(pk)) +            self.assertEqual(response.status_code, 200) +            self.assertEqual(dic_t, json.loads(response.content)) + +            self.assertEqual(dic_f, res_f) +            response = self.client.get(url_pts + get_pk + "0") +            self.assertEqual(response.status_code, 404) +            response = self.client.get(url_pts + get_pk + str(pk)) +            self.assertEqual(response.status_code, 200) +            self.assertEqual(dic_f, json.loads(response.content)) @@ -3307,7 +3000,7 @@ class SeleniumTestsBaseFinds(SeleniumTests):      def test_geo_items(self):          self.selenium.implicitly_wait(5) -        geo_elements, ope_pks = self.setUpDefaultGeoItems() +        geo_elements, pks = self.setUpDefaultGeoItems()          poly_bf, centr_bf, pt_bf = geo_elements[2]          dic_polygon = {  | 
