@@ -266,7 +266,9 @@ async def test_load_tool_not_found_in_manifest(aioresponses, test_tool_str):
266
266
)
267
267
268
268
async with ToolboxClient (TEST_BASE_URL ) as client :
269
- with pytest .raises (Exception , match = f"Tool '{ REQUESTED_TOOL_NAME } ' not found!" ):
269
+ with pytest .raises (
270
+ ValueError , match = f"Tool '{ REQUESTED_TOOL_NAME } ' not found!"
271
+ ):
270
272
await client .load_tool (REQUESTED_TOOL_NAME )
271
273
272
274
aioresponses .assert_called_once_with (
@@ -474,7 +476,7 @@ async def test_bind_params_fail(self, tool_name, client):
474
476
assert len (tool .__signature__ .parameters ) == 2
475
477
assert "argA" in tool .__signature__ .parameters
476
478
477
- with pytest .raises (Exception ) as e :
479
+ with pytest .raises (ValueError ) as e :
478
480
tool .bind_params ({"argC" : lambda : 5 })
479
481
assert "unable to bind parameters: no parameter named argC" in str (e .value )
480
482
@@ -605,138 +607,7 @@ async def test_bind_param_fail(self, tool_name, client):
605
607
assert len (tool .__signature__ .parameters ) == 2
606
608
assert "argA" in tool .__signature__ .parameters
607
609
608
- with pytest .raises (Exception ) as e :
609
- tool .bind_param ("argC" , lambda : 5 )
610
- assert "unable to bind parameters: no parameter named argC" in str (e .value )
611
-
612
- @pytest .mark .asyncio
613
- async def test_rebind_param_fail (self , tool_name , client ):
614
- """
615
- Tests that 'bind_param' fails when attempting to re-bind a
616
- parameter that has already been bound.
617
- """
618
- tool = await client .load_tool (tool_name )
619
-
620
- assert len (tool .__signature__ .parameters ) == 2
621
- assert "argA" in tool .__signature__ .parameters
622
-
623
- tool_with_bound_param = tool .bind_param ("argA" , lambda : 10 )
624
-
625
- assert len (tool_with_bound_param .__signature__ .parameters ) == 1
626
- assert "argA" not in tool_with_bound_param .__signature__ .parameters
627
-
628
610
with pytest .raises (ValueError ) as e :
629
- tool_with_bound_param .bind_param ("argA" , lambda : 20 )
630
-
631
- assert "cannot re-bind parameter: parameter 'argA' is already bound" in str (
632
- e .value
633
- )
634
-
635
- @pytest .mark .asyncio
636
- async def test_bind_param_static_value_success (self , tool_name , client ):
637
- """
638
- Tests bind_param method with a static value.
639
- """
640
-
641
- bound_value = "Test value"
642
-
643
- tool = await client .load_tool (tool_name )
644
- bound_tool = tool .bind_param ("argB" , bound_value )
645
-
646
- assert bound_tool is not tool
647
- assert "argB" not in bound_tool .__signature__ .parameters
648
- assert "argA" in bound_tool .__signature__ .parameters
649
-
650
- passed_value_a = 42
651
- res_payload = await bound_tool (argA = passed_value_a )
652
-
653
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
654
-
655
- @pytest .mark .asyncio
656
- async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
657
- """
658
- Tests bind_param method with a sync callable value.
659
- """
660
-
661
- bound_value_result = True
662
- bound_sync_callable = Mock (return_value = bound_value_result )
663
-
664
- tool = await client .load_tool (tool_name )
665
- bound_tool = tool .bind_param ("argB" , bound_sync_callable )
666
-
667
- assert bound_tool is not tool
668
- assert "argB" not in bound_tool .__signature__ .parameters
669
- assert "argA" in bound_tool .__signature__ .parameters
670
-
671
- passed_value_a = 42
672
- res_payload = await bound_tool (argA = passed_value_a )
673
-
674
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
675
- bound_sync_callable .assert_called_once ()
676
-
677
- @pytest .mark .asyncio
678
- async def test_bind_param_async_callable_value_success (self , tool_name , client ):
679
- """
680
- Tests bind_param method with an async callable value.
681
- """
682
-
683
- bound_value_result = True
684
- bound_async_callable = AsyncMock (return_value = bound_value_result )
685
-
686
- tool = await client .load_tool (tool_name )
687
- bound_tool = tool .bind_param ("argB" , bound_async_callable )
688
-
689
- assert bound_tool is not tool
690
- assert "argB" not in bound_tool .__signature__ .parameters
691
- assert "argA" in bound_tool .__signature__ .parameters
692
-
693
- passed_value_a = 42
694
- res_payload = await bound_tool (argA = passed_value_a )
695
-
696
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
697
- bound_async_callable .assert_awaited_once ()
698
-
699
- @pytest .mark .asyncio
700
- async def test_bind_param_success (self , tool_name , client ):
701
- """Tests 'bind_param' with a bound parameter specified."""
702
- tool = await client .load_tool (tool_name )
703
-
704
- assert len (tool .__signature__ .parameters ) == 2
705
- assert "argA" in tool .__signature__ .parameters
706
-
707
- tool = tool .bind_param ("argA" , 5 )
708
-
709
- assert len (tool .__signature__ .parameters ) == 1
710
- assert "argA" not in tool .__signature__ .parameters
711
-
712
- res = await tool (True )
713
- assert "argA" in res
714
-
715
- @pytest .mark .asyncio
716
- async def test_bind_callable_param_success (self , tool_name , client ):
717
- """Tests 'bind_param' with a bound parameter specified."""
718
- tool = await client .load_tool (tool_name )
719
-
720
- assert len (tool .__signature__ .parameters ) == 2
721
- assert "argA" in tool .__signature__ .parameters
722
-
723
- tool = tool .bind_param ("argA" , lambda : 5 )
724
-
725
- assert len (tool .__signature__ .parameters ) == 1
726
- assert "argA" not in tool .__signature__ .parameters
727
-
728
- res = await tool (True )
729
- assert "argA" in res
730
-
731
- @pytest .mark .asyncio
732
- async def test_bind_param_fail (self , tool_name , client ):
733
- """Tests 'bind_param' with a bound parameter that doesn't exist."""
734
- tool = await client .load_tool (tool_name )
735
-
736
- assert len (tool .__signature__ .parameters ) == 2
737
- assert "argA" in tool .__signature__ .parameters
738
-
739
- with pytest .raises (Exception ) as e :
740
611
tool .bind_param ("argC" , lambda : 5 )
741
612
assert "unable to bind parameters: no parameter named argC" in str (e .value )
742
613
0 commit comments