2020
2121from aistore .sdk .batch .types import MossIn , MossReq
2222
23-
2423# ---------------------------------------------------------------------------
2524# Field presence: the fast path passes specific kwargs to MossIn — assert
2625# they're all real fields on the current SDK so a rename surfaces here.
@@ -44,9 +43,7 @@ def test_mossin_obj_name_is_required():
4443 """``obj_name`` is the only required field today; if more get added,
4544 the fast path's kwargs-sparse build silently produces an invalid request."""
4645 required = [
47- name
48- for name , info in MossIn .model_fields .items ()
49- if info .is_required ()
46+ name for name , info in MossIn .model_fields .items () if info .is_required ()
5047 ]
5148 assert set (required ) <= {"obj_name" }, (
5249 f"MossIn introduced new required fields { set (required ) - {'obj_name' }} "
@@ -65,18 +62,39 @@ def test_mossin_obj_name_is_required():
6562
6663_FAST_KWARG_COMBOS = [
6764 # (description, kwargs)
68- ("url-only (e.g. recording.source.type='url')" ,
69- {"obj_name" : "audio.wav" , "bck" : "bkt" , "provider" : "ais" }),
70- ("url with archpath (tar member)" ,
71- {"obj_name" : "shard.tar" , "bck" : "bkt" , "provider" : "ais" , "archpath" : "rec1.wav" }),
72- ("shar_ptr (byte-range)" ,
73- {"obj_name" : "shard.tar" , "bck" : "bkt" , "provider" : "ais" , "start" : 4096 , "length" : 65536 }),
74- ("aws provider variant" ,
75- {"obj_name" : "shard.tar" , "bck" : "bkt" , "provider" : "aws" }),
65+ (
66+ "url-only (e.g. recording.source.type='url')" ,
67+ {"obj_name" : "audio.wav" , "bck" : "bkt" , "provider" : "ais" },
68+ ),
69+ (
70+ "url with archpath (tar member)" ,
71+ {
72+ "obj_name" : "shard.tar" ,
73+ "bck" : "bkt" ,
74+ "provider" : "ais" ,
75+ "archpath" : "rec1.wav" ,
76+ },
77+ ),
78+ (
79+ "shar_ptr (byte-range)" ,
80+ {
81+ "obj_name" : "shard.tar" ,
82+ "bck" : "bkt" ,
83+ "provider" : "ais" ,
84+ "start" : 4096 ,
85+ "length" : 65536 ,
86+ },
87+ ),
88+ (
89+ "aws provider variant" ,
90+ {"obj_name" : "shard.tar" , "bck" : "bkt" , "provider" : "aws" },
91+ ),
7692]
7793
7894
79- @pytest .mark .parametrize ("desc,kwargs" , _FAST_KWARG_COMBOS , ids = [c [0 ] for c in _FAST_KWARG_COMBOS ])
95+ @pytest .mark .parametrize (
96+ "desc,kwargs" , _FAST_KWARG_COMBOS , ids = [c [0 ] for c in _FAST_KWARG_COMBOS ]
97+ )
8098def test_model_construct_matches_validating_constructor (desc : str , kwargs : dict ):
8199 """``MossIn.model_construct(**kwargs)`` must serialize identically to
82100 ``MossIn(**kwargs)`` — same field values, same defaults for omitted
@@ -119,6 +137,7 @@ def test_mossreq_has_moss_in_list_field():
119137 annotation = MossReq .model_fields ["moss_in" ].annotation
120138 # typing.List[MossIn] subscripts; check origin is list-like.
121139 import typing as _t
140+
122141 assert _t .get_origin (annotation ) is list , (
123142 f"MossReq.moss_in type changed from List[MossIn] to { annotation } "
124143 f"on aistore { aistore .__version__ } . Fast path's append() may break."
@@ -141,6 +160,7 @@ def test_batch_requests_list_is_public_accessor():
141160 # Most robust check is source inspection (kept lenient — only flag a hard
142161 # rename of 'moss_in', anything else gets caught by the round-trip tests).
143162 import inspect
163+
144164 src = inspect .getsource (descriptor .fget )
145165 assert "moss_in" in src , (
146166 f"Batch.requests_list source no longer references moss_in on "
0 commit comments