Skip to content

Commit b7953a8

Browse files
committed
#33 , corrected test cases.
1 parent 8def819 commit b7953a8

6 files changed

+26
-16
lines changed

pydggsapi/test/test_core_dggrs_description.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def test_core_dggrs_description():
2828
assert "not supported" in response.text
2929
assert response.status_code == 400
3030

31-
os.environ['dggs_api_config'] = './dggs_api_config.json'
32-
app = reload(pydggsapi.api).app
33-
client = TestClient(app)
31+
3432
print("Success test case with dggs description (igeo7)")
3533
response = client.get('/dggs-api/v1-pre/dggs/igeo7')
3634
pprint(response.json())

pydggsapi/test/test_core_dggrs_zoneinfo.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ def test_core_dggs_zoneinfo():
4040
assert "not supported" in response.text
4141
assert response.status_code == 400
4242

43-
os.environ['dggs_api_config'] = './dggs_api_config.json'
44-
app = reload(pydggsapi.api).app
45-
client = TestClient(app)
4643
print(f"Success test case with dggs zone info (igeo7 {cellids[0]})")
4744
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}')
4845
pprint(response.json())

pydggsapi/test/test_data-retrieval_query_zone_data.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_data_retrieval():
5656
assert response.status_code == 400
5757

5858
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]})")
59-
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data')
59+
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', params={'depth': '0'})
6060
pprint(response.json())
6161
data = ZonesDataDggsJsonResponse(**response.json())
6262
p1 = list(data.properties.keys())[0]
@@ -65,27 +65,28 @@ def test_data_retrieval():
6565
assert len(value.data) > 0
6666
assert response.status_code == 200
6767

68-
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]}, return = geojson)")
69-
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', headers={'accept': 'application/geo+json'})
68+
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]}, depth=[0] ,return = geojson)")
69+
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', headers={'accept': 'application/geo+json'},
70+
params={'depth': '0'})
7071
pprint(response.json())
7172
data = ZonesDataGeoJson(**response.json())
7273
assert len(data.features) > 0
7374
assert response.status_code == 200
7475

75-
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]}, return = geojson, geometry='zone-centroid')")
76-
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', params={'geometry': 'zone-centroid'},
76+
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]}, depth=[0],return = geojson, geometry='zone-centroid')")
77+
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', params={'geometry': 'zone-centroid', 'depth': '0'},
7778
headers={'accept': 'application/geo+json'})
7879
pprint(response.json())
7980
data = ZonesDataGeoJson(**response.json())
8081
assert response.status_code == 200
8182

8283
print(f"Success test case with data-retrieval query (igeo7, {cellids[0]}, relative_depth=2)")
83-
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', params={'depth': 2})
84+
response = client.get(f'/dggs-api/v1-pre/dggs/igeo7/zones/{cellids[0]}/data', params={'depth': '2'})
8485
pprint(response.json())
8586
data = ZonesDataDggsJsonResponse(**response.json())
8687
p1 = list(data.properties.keys())[0]
8788
assert len(data.values[p1]) > 0
88-
assert (8 in data.depths)
89+
assert (2 in data.depths)
8990
value = data.values[p1][0]
9091
assert len(value.data) > 0
9192
assert response.status_code == 200
@@ -96,7 +97,7 @@ def test_data_retrieval():
9697
data = ZonesDataDggsJsonResponse(**response.json())
9798
p1 = list(data.properties.keys())[0]
9899
assert len(data.values[p1]) > 0
99-
assert (7 in data.depths) and (8 in data.depths)
100+
assert (1 in data.depths) and (2 in data.depths)
100101
value = data.values[p1][0]
101102
assert len(value.data) > 0
102103
assert response.status_code == 200
@@ -107,7 +108,7 @@ def test_data_retrieval():
107108
data = ZonesDataDggsJsonResponse(**response.json())
108109
p1 = list(data.properties.keys())[0]
109110
assert len(data.values[p1]) > 0
110-
assert (7 in data.depths) and (8 in data.depths) and (6 in data.depths)
111+
assert (1 in data.depths) and (2 in data.depths) and (0 in data.depths)
111112
value = data.values[p1][0]
112113
assert len(value.data) > 0
113114
assert response.status_code == 200

pydggsapi/test/test_data-retrieval_query_zone_data_H3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_data_retrieval_h3():
4040
print(f"Fail test case withdata-retrieval query (h3, {cellids[0]}, relative_depth=4) over refinement")
4141
response = client.get(f'/dggs-api/v1-pre/dggs/h3/zones/{cellids[0]}/data', params={'depth': 4})
4242
pprint(response.json())
43-
assert "not supported" in response.text
4443
assert response.status_code == 400
4544

4645
print(f"Success test case with data-retrieval query (h3, {cellids[0]})")

pydggsapi/test/test_zone-query_dggrs_zones.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ def test_zone_query_dggrs_zones():
9595
assert all([validation_zones_list[i] == z for i, z in enumerate(return_zones_list)])
9696
assert response.status_code == 200
9797

98+
print(f"Success test case with dggs zones query (igeo7, bbox: {aoi.bounds}, zone_level=2, compact=False)")
99+
response = client.get('/dggs-api/v1-pre/dggs/igeo7/zones', params={"bbox": ",".join(bounds), 'zone_level': 2, 'compact_zone': False})
100+
pprint(response.json())
101+
zones = ZonesResponse(**response.json())
102+
return_zones_list = zones.zones
103+
assert len(return_zones_list) > 0
104+
assert response.status_code == 200
105+
98106
print(f"Success test case with dggs zones query (igeo7, bbox: {aoi.bounds}, zone_level=8, compact=False, geojson)")
99107
response = client.get('/dggs-api/v1-pre/dggs/igeo7/zones', headers={'Accept': 'Application/geo+json'},
100108
params={"bbox": ",".join(bounds), 'zone_level': 8, 'compact_zone': False})

pydggsapi/test/test_zone-query_dggrs_zones_H3.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ def test_zone_query_dggrs_zones_VH3_2_IGEO7():
4646
assert len(zones.zones) > 0
4747
assert response.status_code == 200
4848

49+
print(f"Success test case with dggs zones query (h3, bbox: {aoi.bounds}, zone_level=2, compact=False)")
50+
response = client.get('/dggs-api/v1-pre/dggs/h3/zones', params={"bbox": ",".join(bounds), 'zone_level': 2, 'compact_zone': False})
51+
pprint(response.json())
52+
zones = ZonesResponse(**response.json())
53+
assert len(zones.zones) > 0
54+
assert response.status_code == 200
55+
4956
print(f"Success test case with dggs zones query (h3, bbox: {aoi.bounds}, zone_level=6, compact=False)")
5057
response = client.get('/dggs-api/v1-pre/dggs/h3/zones', params={"bbox": ",".join(bounds), 'zone_level': 6, 'compact_zone': False})
5158
pprint(response.json())

0 commit comments

Comments
 (0)