1717from ..structures .core import StructureFamily
1818from ..structures .data_source import Asset , DataSource , Management
1919from ..utils import safe_json_dump
20+ from .utils import fail_with_status_code
2021
2122pytestmark = pytest .mark .skipif (
2223 sys .platform == "win32" , reason = "Requires Redis service"
@@ -377,14 +378,27 @@ def on_child_created(update):
377378 num = 3 ,
378379 ),
379380 )
381+ params = {
382+ "patch_shape" : "," .join (map (str , [1 , 7 , 13 ])),
383+ "patch_offset" : "," .join (map (str , [2 , 0 , 0 ])),
384+ }
385+
386+ # First test invalid requests that will be bounced by the server.
387+ for key in params :
388+ bad_params = params .copy ()
389+ bad_params .pop (key ) # missing one of the patch params!
390+ with fail_with_status_code (400 ):
391+ x .context .http_client .put (
392+ x .uri .replace ("/metadata/" , "/data_source/" , 1 ),
393+ content = safe_json_dump ({"data_source" : updated_data_source }),
394+ params = bad_params ,
395+ ).raise_for_status ()
396+
397+ # Now do a request that is valid.
380398 x .context .http_client .put (
381399 x .uri .replace ("/metadata/" , "/data_source/" , 1 ),
382- content = safe_json_dump (
383- {
384- "data_source" : updated_data_source ,
385- "patch" : {"shape" : (1 , 7 , 13 ), "offset" : (2 , 0 , 0 ), "extend" : True },
386- }
387- ),
400+ content = safe_json_dump ({"data_source" : updated_data_source }),
401+ params = params ,
388402 ).raise_for_status ()
389403 assert event .wait (timeout = 5.0 ), "Timeout waiting for messages"
390404 x .close_stream ()
@@ -395,7 +409,6 @@ def on_child_created(update):
395409 (update ,) = updates
396410 assert update .patch .shape == (1 , 7 , 13 )
397411 assert update .patch .offset == (2 , 0 , 0 )
398- assert update .patch .extend
399412 actual_streamed = update .data ()
400413 np .testing .assert_array_equal (actual_streamed , arr [2 :])
401414
@@ -519,7 +532,7 @@ def collect(update):
519532 assert_frame_equal (actual_updated , df2 )
520533
521534
522- def test_streaming_table_appends (tiled_websocket_context ):
535+ def test_streaming_table_append (tiled_websocket_context ):
523536 context = tiled_websocket_context
524537 client = from_context (context )
525538 updates = []
0 commit comments