File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 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+ )
You can’t perform that action at this time.
0 commit comments