@@ -373,8 +373,11 @@ def test_issue_1196(self):
373
373
config = connections .get_connection_addr ("default" )
374
374
assert config == {"address" : 'localhost:19531' , "user" : 'root' , "secure" : True }
375
375
376
- def test_issue_2670 (self ):
376
+ @pytest .mark .parametrize ("uri, db_name" , [("http://localhost:19530" , "test_db" ), ("http://localhost:19530/" , "test_db" ), ("http://localhost:19530/test_db" , None )])
377
+ def test_issue_2670_2727 (self , uri : str , db_name : str | None ):
377
378
"""
379
+ Issue 2670:
380
+
378
381
Test for db_name being overwritten with empty string, when the uri
379
382
ends in a slash - e.g. http://localhost:19530/
380
383
@@ -384,16 +387,28 @@ def test_issue_2670(self):
384
387
it will overwrite the db_name with an empty string.
385
388
Expected and current behaviour: if db_name is passed explicitly,
386
389
it should be used in the initialization of the GrpcHandler.
390
+
391
+ Issue 2727:
392
+ If db_name is passed as a path to the uri and not explicitly passed as an argument,
393
+ it is not overwritten with an empty string.
394
+
395
+ See: https://github.com/milvus-io/pymilvus/issues/2727
396
+
397
+ Actual behaviour before fix: if db_name is passed as a path to the uri,
398
+ it will overwrite the db_name with an empty string.
399
+ Expected and current behaviour: if db_name is passed as a path to the uri,
400
+ it should be used in the initialization of the GrpcHandler.
387
401
388
402
"""
389
- db_name = "default"
390
- alias = self .test_issue_2670 .__name__
403
+ alias = self .test_issue_2670_2727 .__name__
391
404
392
405
with mock .patch (f"{ mock_prefix } .__init__" , return_value = None ) as mock_init , mock .patch (
393
406
f"{ mock_prefix } ._wait_for_channel_ready" , return_value = None ):
394
- config = {"alias" : alias , "uri" : "http://localhost:19530/" , "db_name" : db_name }
407
+ config = {"alias" : alias , "uri" : uri , "db_name" : db_name }
395
408
connections .connect (** config )
396
409
410
+ db_name = db_name or uri .split ("/" )[- 1 ]
411
+
397
412
mock_init .assert_called_with (
398
413
** {'address' : 'localhost:19530' , 'user' : '' , 'password' : '' , 'token' : '' , 'db_name' : db_name }
399
414
)
0 commit comments