1
1
import json
2
2
import os
3
+ import pytest
3
4
4
5
from helpers import find_string_in_stream
5
6
9
10
test_unconsolidated_store = os .path .join (DATA_DIR , "unconsolidated.zarr" )
10
11
test_pyramid_store = os .path .join (DATA_DIR , "pyramid.zarr" )
11
12
12
- test_zarr_store_params = {
13
+ store_params = {}
14
+
15
+ store_params ["zarr_store" ] = {
13
16
"params" : {
14
17
"url" : test_zarr_store ,
15
18
"variable" : "CDD0" ,
19
22
"variables" : ["CDD0" , "DISPH" , "FROST_DAYS" , "GWETPROF" ],
20
23
}
21
24
22
- test_netcdf_store_params = {
25
+ store_params [ "netcdf_store" ] = {
23
26
"params" : {
24
27
"url" : test_netcdf_store ,
25
28
"variable" : "data" ,
28
31
},
29
32
"variables" : ["data" ],
30
33
}
31
- test_unconsolidated_store_params = {
34
+ store_params [ "unconsolidated_store" ] = {
32
35
"params" : {
33
36
"url" : test_unconsolidated_store ,
34
37
"variable" : "var1" ,
37
40
},
38
41
"variables" : ["var1" , "var2" ],
39
42
}
40
- test_pyramid_store_params = {
43
+ store_params [ "pyramid_store" ] = {
41
44
"params" : {
42
45
"url" : test_pyramid_store ,
43
46
"variable" : "value" ,
@@ -60,20 +63,9 @@ def get_variables_test(app, ds_params):
60
63
assert timings [1 ].lstrip ().startswith ("1-xarray-open_dataset;dur=" )
61
64
62
65
63
- def test_get_variables_test (app ):
64
- return get_variables_test (app , test_zarr_store_params )
65
-
66
-
67
- def test_get_variables_netcdf (app ):
68
- return get_variables_test (app , test_netcdf_store_params )
69
-
70
-
71
- def test_get_variables_unconsolidated (app ):
72
- return get_variables_test (app , test_unconsolidated_store_params )
73
-
74
-
75
- def test_get_variables_pyramid (app ):
76
- return get_variables_test (app , test_pyramid_store_params )
66
+ @pytest .mark .parametrize ("store_params" , store_params .values (), ids = store_params .keys ())
67
+ def test_get_variables (store_params , app ):
68
+ return get_variables_test (app , store_params )
77
69
78
70
79
71
def get_info_test (app , ds_params ):
@@ -90,20 +82,9 @@ def get_info_test(app, ds_params):
90
82
assert response .json () == json .load (f )
91
83
92
84
93
- def test_get_info_test (app ):
94
- return get_info_test (app , test_zarr_store_params )
95
-
96
-
97
- def test_get_info_netcdf (app ):
98
- return get_info_test (app , test_netcdf_store_params )
99
-
100
-
101
- def test_get_info_unconsolidated (app ):
102
- return get_info_test (app , test_unconsolidated_store_params )
103
-
104
-
105
- def test_get_info_pyramid (app ):
106
- return get_info_test (app , test_pyramid_store_params )
85
+ @pytest .mark .parametrize ("store_params" , store_params .values (), ids = store_params .keys ())
86
+ def test_get_info (store_params , app ):
87
+ return get_info_test (app , store_params )
107
88
108
89
109
90
def get_tilejson_test (app , ds_params ):
@@ -121,20 +102,9 @@ def get_tilejson_test(app, ds_params):
121
102
assert response .json () == json .load (f )
122
103
123
104
124
- def test_get_tilejson_test (app ):
125
- return get_tilejson_test (app , test_zarr_store_params )
126
-
127
-
128
- def test_get_tilejson_netcdf (app ):
129
- return get_tilejson_test (app , test_netcdf_store_params )
130
-
131
-
132
- def test_get_tilejson_unconsolidated (app ):
133
- return get_tilejson_test (app , test_unconsolidated_store_params )
134
-
135
-
136
- def test_get_tilejson_pyramid (app ):
137
- return get_tilejson_test (app , test_pyramid_store_params )
105
+ @pytest .mark .parametrize ("store_params" , store_params .values (), ids = store_params .keys ())
106
+ def test_get_tilejson (store_params , app ):
107
+ return get_tilejson_test (app , store_params )
138
108
139
109
140
110
def get_tile_test (app , ds_params , zoom : int = 0 ):
@@ -151,22 +121,14 @@ def get_tile_test(app, ds_params, zoom: int = 0):
151
121
assert timings [2 ].lstrip ().startswith ("2-rioxarray-reproject;dur=" )
152
122
153
123
154
- def test_get_tile_test (app ):
155
- return get_tile_test (app , test_zarr_store_params )
156
-
157
-
158
- def test_get_tile_netcdf (app ):
159
- return get_tile_test (app , test_netcdf_store_params )
160
-
161
-
162
- def test_get_tile_unconsolidated (app ):
163
- return get_tile_test (app , test_unconsolidated_store_params )
164
-
165
-
166
- def test_get_tile_pyramid (app ):
167
- # test that even a group outside of the range will return a tile
168
- for z in range (3 ):
169
- get_tile_test (app , test_pyramid_store_params , zoom = z )
124
+ @pytest .mark .parametrize ("store_params" , store_params .values (), ids = store_params .keys ())
125
+ def test_get_tile (store_params , app ):
126
+ # if the store is a pyramid we test zoom levels 0-2
127
+ if "group" in store_params ["params" ]:
128
+ for z in range (3 ):
129
+ get_tile_test (app , store_params , zoom = z )
130
+ else :
131
+ get_tile_test (app , store_params )
170
132
171
133
172
134
def histogram_test (app , ds_params ):
@@ -182,20 +144,9 @@ def histogram_test(app, ds_params):
182
144
assert response .json () == json .load (f )
183
145
184
146
185
- def test_histogram_test (app ):
186
- return histogram_test (app , test_zarr_store_params )
187
-
188
-
189
- def test_histogram_netcdf (app ):
190
- return histogram_test (app , test_netcdf_store_params )
191
-
192
-
193
- def test_histogram_unconsolidated (app ):
194
- return histogram_test (app , test_unconsolidated_store_params )
195
-
196
-
197
- def test_histogram_pyramid (app ):
198
- return histogram_test (app , test_pyramid_store_params )
147
+ @pytest .mark .parametrize ("store_params" , store_params .values (), ids = store_params .keys ())
148
+ def test_histogram (store_params , app ):
149
+ return histogram_test (app , store_params )
199
150
200
151
201
152
def test_histogram_error (app ):
0 commit comments