@@ -57,7 +57,8 @@ def test_count_function_attach_and_detach(basic_http_client: System) -> None:
5757 assert result ["metadatas" ][0 ]["total_count" ] == 300
5858
5959 # Remove the task
60- success = attached_fn .detach (
60+ success = collection .detach_function (
61+ attached_fn .name ,
6162 delete_output_collection = True ,
6263 )
6364
@@ -108,7 +109,7 @@ def test_attach_function_returns_function_name(basic_http_client: System) -> Non
108109 assert retrieved_fn == attached_fn
109110
110111 # Clean up
111- attached_fn . detach ( delete_output_collection = True )
112+ collection . detach_function ( attached_fn . name , delete_output_collection = True )
112113
113114
114115def test_function_multiple_collections (basic_http_client : System ) -> None :
@@ -146,8 +147,14 @@ def test_function_multiple_collections(basic_http_client: System) -> None:
146147 assert attached_fn1 .id != attached_fn2 .id
147148
148149 # Clean up
149- assert attached_fn1 .detach (delete_output_collection = True ) is True
150- assert attached_fn2 .detach (delete_output_collection = True ) is True
150+ assert (
151+ collection1 .detach_function (attached_fn1 .name , delete_output_collection = True )
152+ is True
153+ )
154+ assert (
155+ collection2 .detach_function (attached_fn2 .name , delete_output_collection = True )
156+ is True
157+ )
151158
152159
153160def test_functions_one_attached_function_per_collection (
@@ -191,7 +198,10 @@ def test_functions_one_attached_function_per_collection(
191198 )
192199
193200 # Detach the first function
194- assert attached_fn1 .detach (delete_output_collection = True ) is True
201+ assert (
202+ collection .detach_function (attached_fn1 .name , delete_output_collection = True )
203+ is True
204+ )
195205
196206 # Now we should be able to attach a new function
197207 attached_fn2 = collection .attach_function (
@@ -205,7 +215,10 @@ def test_functions_one_attached_function_per_collection(
205215 assert attached_fn2 .id != attached_fn1 .id
206216
207217 # Clean up
208- assert attached_fn2 .detach (delete_output_collection = True ) is True
218+ assert (
219+ collection .detach_function (attached_fn2 .name , delete_output_collection = True )
220+ is True
221+ )
209222
210223
211224def test_function_remove_nonexistent (basic_http_client : System ) -> None :
@@ -222,11 +235,12 @@ def test_function_remove_nonexistent(basic_http_client: System) -> None:
222235 params = None ,
223236 )
224237
225- attached_fn . detach ( delete_output_collection = True )
238+ collection . detach_function ( attached_fn . name , delete_output_collection = True )
226239
227240 # Trying to detach this function again should raise NotFoundError
228241 with pytest .raises (NotFoundError , match = "does not exist" ):
229- attached_fn .detach (delete_output_collection = True )
242+ collection .detach_function (attached_fn .name , delete_output_collection = True )
243+
230244
231245def test_attach_to_output_collection_fails (basic_http_client : System ) -> None :
232246 """Test that attaching a function to an output collection fails"""
@@ -245,14 +259,17 @@ def test_attach_to_output_collection_fails(basic_http_client: System) -> None:
245259 )
246260 output_collection = client .get_collection (name = "output_collection" )
247261
248- with pytest .raises (ChromaError , match = "cannot attach function to an output collection" ):
262+ with pytest .raises (
263+ ChromaError , match = "cannot attach function to an output collection"
264+ ):
249265 _ = output_collection .attach_function (
250266 name = "test_function_2" ,
251267 function_id = "record_counter" ,
252268 output_collection = "output_collection_2" ,
253269 params = None ,
254270 )
255271
272+
256273def test_delete_output_collection_detaches_function (basic_http_client : System ) -> None :
257274 """Test that deleting an output collection also detaches the attached function"""
258275 client = ClientCreator .from_system (basic_http_client )
@@ -277,6 +294,7 @@ def test_delete_output_collection_detaches_function(basic_http_client: System) -
277294 with pytest .raises (NotFoundError ):
278295 input_collection .get_attached_function ("my_function" )
279296
297+
280298def test_delete_orphaned_output_collection (basic_http_client : System ) -> None :
281299 """Test that deleting an output collection from a recently detached function works"""
282300 client = ClientCreator .from_system (basic_http_client )
@@ -294,15 +312,15 @@ def test_delete_orphaned_output_collection(basic_http_client: System) -> None:
294312 )
295313 assert attached_fn is not None
296314
297- attached_fn . detach ( delete_output_collection = False )
315+ input_collection . detach_function ( attached_fn . name , delete_output_collection = False )
298316
299317 # Delete the output collection directly
300318 client .delete_collection ("output_collection" )
301319
302320 # The attached function should still exist but be marked as detached
303321 with pytest .raises (NotFoundError ):
304322 input_collection .get_attached_function ("my_function" )
305-
323+
306324 with pytest .raises (NotFoundError ):
307325 # Try to use the function - it should fail since it's detached
308- client .get_collection ("output_collection" )
326+ client .get_collection ("output_collection" )
0 commit comments