22from unittest .mock import MagicMock , patch
33from iclaw .commands import model , search_provider , auth , utils
44
5+
56class TestCommands (unittest .TestCase ):
67 @patch ("iclaw.commands.model.get_models" )
78 @patch ("iclaw.commands.model.input" , return_value = "1" )
@@ -19,12 +20,13 @@ def test_handle_search_provider_command(self, mock_input):
1920
2021 @patch ("iclaw.commands.auth.get_device_code" )
2122 @patch ("iclaw.commands.auth.poll_for_access_token" )
22- def test_handle_login_command (self , mock_poll , mock_device ):
23- mock_device .return_value = {"device_code" : "dc" }
23+ @patch ("iclaw.commands.auth.input" , return_value = "1" )
24+ def test_handle_login_command (self , mock_input , mock_poll , mock_device ):
25+ mock_device .return_value = {"device_code" : "dc" , "interval" : 5 }
2426 mock_poll .return_value = "at"
2527 mock_path = MagicMock ()
2628 with patch ("sys.stdout" ):
27- res = auth .handle_login_command (mock_path , 1 )
29+ res = auth .handle_login_command (mock_path )
2830 self .assertEqual (res , "at" )
2931
3032 @patch ("iclaw.commands.utils.sys" )
@@ -36,5 +38,6 @@ def test_handle_copy_command(self, mock_sys):
3638 utils .handle_copy_command ("text" )
3739 mock_py .copy .assert_called_with ("text" )
3840
41+
3942if __name__ == "__main__" :
4043 unittest .main ()
0 commit comments