@@ -342,6 +342,32 @@ class Model2(BaseModel):
342342 assert isinstance (response , Model1 )
343343 assert response .foo == 1
344344
345+ def test_base_url_trailing_slash (self ) -> None :
346+ client = Finch (
347+ base_url = "http://localhost:5000/custom/path/" , access_token = access_token , _strict_response_validation = True
348+ )
349+ request = client ._build_request (
350+ FinalRequestOptions (
351+ method = "post" ,
352+ url = "/foo" ,
353+ json_data = {"foo" : "bar" },
354+ ),
355+ )
356+ assert request .url == "http://localhost:5000/custom/path/foo"
357+
358+ def test_base_url_no_trailing_slash (self ) -> None :
359+ client = Finch (
360+ base_url = "http://localhost:5000/custom/path" , access_token = access_token , _strict_response_validation = True
361+ )
362+ request = client ._build_request (
363+ FinalRequestOptions (
364+ method = "post" ,
365+ url = "/foo" ,
366+ json_data = {"foo" : "bar" },
367+ ),
368+ )
369+ assert request .url == "http://localhost:5000/custom/path/foo"
370+
345371
346372class TestAsyncFinch :
347373 client = AsyncFinch (base_url = base_url , access_token = access_token , _strict_response_validation = True )
@@ -658,3 +684,29 @@ class Model2(BaseModel):
658684 response = await self .client .get ("/foo" , cast_to = cast (Any , Union [Model1 , Model2 ]))
659685 assert isinstance (response , Model1 )
660686 assert response .foo == 1
687+
688+ def test_base_url_trailing_slash (self ) -> None :
689+ client = AsyncFinch (
690+ base_url = "http://localhost:5000/custom/path/" , access_token = access_token , _strict_response_validation = True
691+ )
692+ request = client ._build_request (
693+ FinalRequestOptions (
694+ method = "post" ,
695+ url = "/foo" ,
696+ json_data = {"foo" : "bar" },
697+ ),
698+ )
699+ assert request .url == "http://localhost:5000/custom/path/foo"
700+
701+ def test_base_url_no_trailing_slash (self ) -> None :
702+ client = AsyncFinch (
703+ base_url = "http://localhost:5000/custom/path" , access_token = access_token , _strict_response_validation = True
704+ )
705+ request = client ._build_request (
706+ FinalRequestOptions (
707+ method = "post" ,
708+ url = "/foo" ,
709+ json_data = {"foo" : "bar" },
710+ ),
711+ )
712+ assert request .url == "http://localhost:5000/custom/path/foo"
0 commit comments