Skip to content

Commit 90c52f7

Browse files
committed
test: added basic stac client tests
1 parent 9e93d30 commit 90c52f7

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tests/test_swisstopopy.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
11
"""Tests for swisstopopy."""
22

3-
# Write your tests here
3+
import unittest
4+
5+
import geopandas as gpd
6+
7+
import swisstopopy
8+
9+
10+
class TestSTACClient(unittest.TestCase):
11+
def setUp(self):
12+
self.nominatim_query = "Pully, Switzerland"
13+
self.collection_ids = [
14+
swisstopopy.SWISSALTI3D_COLLECTION_ID,
15+
swisstopopy.SWISSIMAGE10_COLLECTION_ID,
16+
swisstopopy.SWISSSURFACE3D_COLLECTION_ID,
17+
swisstopopy.SWISSSURFACE3D_RASTER_COLLECTION_ID,
18+
]
19+
20+
def test_region(self):
21+
# test without region (all collection items)
22+
client = swisstopopy.SwissTopoClient()
23+
24+
# test init all collections
25+
for collection_id in self.collection_ids:
26+
gdf = client.gdf_from_collection(collection_id)
27+
# test that we get a non empty geo-data frame
28+
self.assertIsInstance(gdf, gpd.GeoDataFrame)
29+
self.assertFalse(gdf.empty)
30+
31+
# now only test one collection (the last one)
32+
region_client = swisstopopy.SwissTopoClient(self.region)
33+
# test that there are at most as many items as when not filtering spatially
34+
self.assertLessEqual(
35+
len(region_client.gdf_from_collection(collection_id).index), len(gdf.index)
36+
)

0 commit comments

Comments
 (0)