@@ -48,6 +48,8 @@ def setUpClass(cls):
48
48
49
49
def test_service_byoa_inline_code (self ):
50
50
"""
51
+ Assert the service can run BYOA with a inline code.
52
+
51
53
This test sets up a generator request with an
52
54
inline user-code configuration
53
55
that will cause the generator to
@@ -62,6 +64,8 @@ def test_service_byoa_inline_code(self):
62
64
63
65
def test_service_byoa_code_package (self ):
64
66
"""
67
+ Assert the service can run BYOA with a code package.
68
+
65
69
This test sets up a generator request with an
66
70
packaged user-code configuration
67
71
that will cause the generator to
@@ -218,7 +222,7 @@ def _test_service_byoa(self, inline_code: bool):
218
222
219
223
def test_service_simple_copy (self ):
220
224
"""
221
- This test sets up a generator request that
225
+ Assert the service can copy.
222
226
223
227
1. opens a dataset "DATASET-1.zarr" in store "@test"
224
228
2. writes this dataset "OUTPUT.zarr" in store "@test"
@@ -253,7 +257,7 @@ def test_service_simple_copy(self):
253
257
254
258
def test_service_empty_cube (self ):
255
259
"""
256
- This test asserts the service fails with a warning.
260
+ Assert the service returns an empty-cube warning.
257
261
"""
258
262
if not self .server_running :
259
263
return
@@ -293,7 +297,7 @@ def test_service_empty_cube(self):
293
297
294
298
def test_service_invalid_request (self ):
295
299
"""
296
- This test asserts the service fails with a 400 status code .
300
+ Assert the service recognizes invalid requests .
297
301
"""
298
302
if not self .server_running :
299
303
return
@@ -326,3 +330,50 @@ def test_service_invalid_request(self):
326
330
' does not exist in store' ,
327
331
result_dict .get ('message' ))
328
332
self .assertEqual (None , result_dict .get ('output' ))
333
+
334
+ def test_service_internal_error (self ):
335
+ """
336
+ Assert the service handles internal errors.
337
+ """
338
+
339
+ if not self .server_running :
340
+ return
341
+
342
+ generator = RemoteCubeGenerator (
343
+ service_config = ServiceConfig (endpoint_url = SERVER_URL )
344
+ )
345
+
346
+ request_dict = {
347
+ "input_configs" : [
348
+ {
349
+ 'store_id' : '@test' ,
350
+ "data_id" : "DATASET-1.zarr"
351
+ }
352
+ ],
353
+ "cube_config" : {
354
+ "metadata" : {
355
+ # This raises a ValueError in "xcube gen2"
356
+ 'inverse_fine_structure_constant' : 138
357
+ }
358
+ },
359
+ "output_config" : {
360
+ "store_id" : "@test" ,
361
+ "data_id" : "OUTPUT.zarr" ,
362
+ "replace" : True ,
363
+ }
364
+ }
365
+
366
+ result = generator .generate_cube (request_dict )
367
+
368
+ result_dict = result .to_dict ()
369
+ self .assertEqual ('error' , result_dict .get ('status' ))
370
+ self .assertEqual (400 , result_dict .get ('status_code' ))
371
+ self .assertEqual (None , result_dict .get ('result' ))
372
+ self .assertEqual ('inverse_fine_structure_constant must be 137'
373
+ ' or running in wrong universe' ,
374
+ result_dict .get ('message' ))
375
+ self .assertEqual (None , result_dict .get ('output' ))
376
+
377
+ # self.assertEqual(('inverse_fine_structure_constant must be 137'
378
+ # ' or running in wrong universe',),
379
+ # cm.exception.args)
0 commit comments