@@ -49,12 +49,12 @@ def _assert_object_row_shape(obj: Dict[str, Any]) -> None:
4949 assert isinstance (obj ["id" ], int )
5050 assert isinstance (obj ["key" ], str )
5151 assert isinstance (obj ["mime_type" ], str )
52- assert isinstance (obj ["source" ], (dict , str , type (None ))) # _row_to_dict tries to coerce
52+ assert isinstance (
53+ obj ["source" ], (dict , str , type (None ))
54+ ) # _row_to_dict tries to coerce
5355
5456
55- def _post_object_files (
56- api_client , files : List [Tuple [str , Tuple [str , bytes , str ]]]
57- ):
57+ def _post_object_files (api_client , files : List [Tuple [str , Tuple [str , bytes , str ]]]):
5858 """
5959 POST /object expects multipart/form-data with one or many files under field name 'object'.
6060
@@ -64,7 +64,9 @@ def _post_object_files(
6464 return api_client .post ("/object" , files = files )
6565
6666
67- def _create_one (api_client , * , name : Optional [str ] = None , content : bytes = b"hello" ) -> Dict [str , Any ]:
67+ def _create_one (
68+ api_client , * , name : Optional [str ] = None , content : bytes = b"hello"
69+ ) -> Dict [str , Any ]:
6870 name = name or f"{ _rand ()} .txt"
6971 resp = _post_object_files (api_client , [("object" , (name , content , "text/plain" ))])
7072 assert resp .status_code == 200
@@ -82,17 +84,21 @@ class CreatedObject:
8284 id : int
8385 key : str
8486
87+
8588@pytest .fixture (scope = "module" )
8689def object_registry (api_client ):
8790 created : List [CreatedObject ] = []
8891 yield created
8992 for obj in reversed (created ):
9093 resp = api_client .delete (f"/object/{ obj .id } ?hard=true" )
91- assert resp . status_code == 200 , (
92- f"Cleanup hard delete failed for id= { obj . id } key= { obj . key } : { resp . text } "
93- )
94+ assert (
95+ resp . status_code == 200
96+ ), f"Cleanup hard delete failed for id= { obj . id } key= { obj . key } : { resp . text } "
9497
95- def _register_created (registry : List [CreatedObject ], objects_created : List [Dict [str , Any ]]) -> None :
98+
99+ def _register_created (
100+ registry : List [CreatedObject ], objects_created : List [Dict [str , Any ]]
101+ ) -> None :
96102 for o in objects_created :
97103 registry .append (CreatedObject (id = o ["id" ], key = o ["key" ]))
98104
@@ -114,7 +120,9 @@ def test_post_requires_field_name_object(self, api_client):
114120
115121 def test_post_single_file_creates_row (self , api_client , object_registry ):
116122 name = f"{ _rand ()} .txt"
117- resp = _post_object_files (api_client , [("object" , (name , b"hello" , "text/plain" ))])
123+ resp = _post_object_files (
124+ api_client , [("object" , (name , b"hello" , "text/plain" ))]
125+ )
118126 assert resp .status_code == 200
119127
120128 out = resp .json ()
@@ -149,13 +157,17 @@ def test_post_multiple_files_creates_multiple(self, api_client, object_registry)
149157 def test_post_duplicate_key_skips (self , api_client , object_registry ):
150158 name = f"{ _rand ()} .txt"
151159
152- r1 = _post_object_files (api_client , [("object" , (name , b"first" , "text/plain" ))])
160+ r1 = _post_object_files (
161+ api_client , [("object" , (name , b"first" , "text/plain" ))]
162+ )
153163 assert r1 .status_code == 200
154164 created1 = r1 .json ()["objects_created" ]
155165 assert len (created1 ) == 1
156166 _register_created (object_registry , created1 )
157167
158- r2 = _post_object_files (api_client , [("object" , (name , b"second" , "text/plain" ))])
168+ r2 = _post_object_files (
169+ api_client , [("object" , (name , b"second" , "text/plain" ))]
170+ )
159171 assert r2 .status_code == 200
160172 created2 = r2 .json ()["objects_created" ]
161173 assert len (created2 ) == 0 # skipped
@@ -236,7 +248,9 @@ def test_patch_updates_source_and_mime_type(self, api_client, object_registry):
236248 assert isinstance (out ["source" ], dict )
237249 assert out ["source" ]["comments" ] == "test"
238250
239- resp2 = api_client .patch (f"/object/{ oid } " , json = {"mime_type" : "application/pdf" })
251+ resp2 = api_client .patch (
252+ f"/object/{ oid } " , json = {"mime_type" : "application/pdf" }
253+ )
240254 assert resp2 .status_code == 200
241255 assert resp2 .json ()["mime_type" ] == "application/pdf"
242256
0 commit comments