summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py160
1 files changed, 116 insertions, 44 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index ddb362fd4..34d7e1b91 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -2592,6 +2592,7 @@ class GeomaticTest(FindInit, TestCase):
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)
@@ -2613,7 +2614,8 @@ class GeomaticTest(FindInit, TestCase):
dic_pt_f_copy = copy.deepcopy(dic_pt_f)
dic_pt_pt_f = copy.deepcopy(dic_pt_f)
dic_pt_pt_f["properties"] = {
- "associated base finds": {"Find 1 from CR Pt Pt": dic_pt_f_copy}
+ "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))
@@ -2622,7 +2624,11 @@ class GeomaticTest(FindInit, TestCase):
"type": "Feature",
"geometry": {"type": "MultiPolygon", "coordinates": []},
"properties": {
- "associated base finds": {"Find 1 from CR Pt Pt": dic_pt_t_copy}
+ "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))
@@ -2673,22 +2679,35 @@ class GeomaticTest(FindInit, TestCase):
[[[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"] = {
- "associated base finds": {"Find 1 from CR Poly Pt": dic_pt_t}
+ "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_copy = copy.deepcopy(dic_pt_f)
+ 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"] = {
- "associated base finds": {"Find 1 from CR Poly Pt": dic_pt_f_copy}
+ "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))
@@ -2727,10 +2746,15 @@ class GeomaticTest(FindInit, TestCase):
)
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, res_poly)
+ 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, res_centroid)
+ self.assertEqual(dic_poly_f_from_poly, res_centroid)
# test API with polygon
response = self.client.get(reverse("api-get-geo-polygons", kwargs={"pk": 0}))
@@ -2742,7 +2766,7 @@ class GeomaticTest(FindInit, TestCase):
)
)
self.assertEqual(response.status_code, 200)
- self.assertIn(json.dumps(dic_poly_t).encode("utf-8"), response.content)
+ self.assertEqual(dic_poly_t_from_poly, json.loads(response.content))
response = self.client.get(
reverse(
"api-get-geo-point",
@@ -2750,32 +2774,47 @@ class GeomaticTest(FindInit, TestCase):
)
)
self.assertEqual(response.status_code, 200)
- self.assertIn(json.dumps(dic_poly_f).encode("utf-8"), response.content)
+ self.assertEqual(dic_poly_f_from_poly, json.loads(response.content))
# 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_copy = copy.deepcopy(dic_poly_t)
+ 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"] = {
- "associated base finds": {
- "Find 1 from CR Poly Poly Pt": dic_poly_t_copy,
- "Find 2 from CR Poly Poly Pt": dic_pt_t_copy,
- }
+ "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_f_copy = copy.deepcopy(dic_poly_f)
dic_poly_poly_and_pt_f = copy.deepcopy(dic_poly_f)
dic_poly_poly_and_pt_f["properties"] = {
- "associated base finds": {
- "Find 1 from CR Poly Poly Pt": dic_poly_f_copy,
- "Find 2 from CR Poly Poly Pt": dic_pt_f_copy,
- }
+ "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)
@@ -2810,27 +2849,44 @@ class GeomaticTest(FindInit, TestCase):
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 point and base find 2 a polygon
+ # context record is a point, base find 1 a polygon and base find 2 a point
cr_pt_poly_and_pt, bfs = create_cr_with_bfs(
ope, "Point", ["Polygon", "Point"], "CR Pt Poly Pt"
)
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"] = {
- "associated base finds": {
- "Find 1 from CR Pt Poly Pt": dic_poly_t_copy,
- "Find 2 from CR Pt Poly Pt": dic_pt_t_copy,
- }
+ "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"] = {
- "associated base finds": {
- "Find 1 from CR Pt Poly Pt": dic_poly_f_copy,
- "Find 2 from CR Pt Poly Pt": dic_pt_f_copy,
- }
+ "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))
@@ -2867,31 +2923,47 @@ class GeomaticTest(FindInit, TestCase):
dic_pt_pt_and_poly_pt_and_poly_f = copy.deepcopy(dic_pt_f)
dic_pt_pt_and_poly_pt_and_poly_f["properties"] = {
- "associated context records": {
- "CR Pt Poly Pt": dic_pt_poly_and_pt_f,
- "CR Poly Poly Pt": dic_poly_poly_and_pt_f,
- }
+ "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"] = {
- "associated context records": {
- "CR Pt Poly Pt": dic_pt_poly_and_pt_t,
- "CR Poly Poly Pt": dic_poly_poly_and_pt_t,
- }
+ "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_f = copy.deepcopy(dic_poly_f)
dic_poly_pt_and_poly_pt_and_poly_f["properties"] = {
- "associated context records": {
- "CR Pt Poly Pt": dic_pt_poly_and_pt_f,
- "CR Poly Poly Pt": dic_poly_poly_and_pt_f,
- }
+ "context-records": {
+ "type": "FeatureCollection",
+ "features": [
+ dic_poly_poly_and_pt_f,
+ dic_pt_poly_and_pt_f,
+ ],
+ },
+ "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"] = {
- "associated context records": {
- "CR Pt Poly Pt": dic_pt_poly_and_pt_t,
- "CR Poly Poly Pt": dic_poly_poly_and_pt_t,
- }
+ "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)