@@ -21,56 +21,54 @@ def test_default_initialization(self) -> None:
2121 client = OllamaClient ()
2222 assert client .base_url == "http://localhost:11434"
2323 assert client .model == "gpt-oss:20b"
24- assert client .session is not None
2524
2625 def test_custom_initialization (self ) -> None :
2726 """Test client accepts custom configuration"""
2827 client = OllamaClient (host = "custom.host" , port = 8080 , model = "custom:model" )
2928 assert client .base_url == "http://custom.host:8080"
3029 assert client .model == "custom:model"
3130
32- def test_session_persistence (self ) -> None :
33- """Test that session object persists across calls"""
34- client = OllamaClient ()
35- session1 = client .session
36- session2 = client .session
37- assert session1 is session2
31+ def test_seed_initialization (self ) -> None :
32+ """Test that seed parameter is properly stored"""
33+ client = OllamaClient (seed = 42 )
34+ assert client .seed == 42
35+
36+ client_no_seed = OllamaClient ()
37+ assert client_no_seed .seed is None
3838
3939
4040class TestOllamaClientModelAvailability :
4141 """Test model availability checking"""
4242
43- @patch ('src.utils.model_client.requests.Session ' )
44- def test_model_available (self , mock_session_class ) -> None :
43+ @patch ('src.utils.model_client.requests.get ' )
44+ def test_model_available (self , mock_get ) -> None :
4545 """Test when model is available"""
46- mock_session = MagicMock ()
4746 mock_response = MagicMock ()
4847 mock_response .json .return_value = {
4948 "models" : [
5049 {"name" : "gpt-oss:20b" },
5150 {"name" : "other:model" }
5251 ]
5352 }
54- mock_session . get .return_value = mock_response
55- mock_session_class .return_value = mock_session
53+ mock_response . raise_for_status .return_value = None
54+ mock_get .return_value = mock_response
5655
5756 client = OllamaClient ()
5857 assert client .is_model_available () is True
59- mock_session . get .assert_called_once_with (
58+ mock_get .assert_called_once_with (
6059 "http://localhost:11434/api/tags" ,
6160 timeout = 180
6261 )
6362
64- @patch ('src.utils.model_client.requests.Session ' )
65- def test_model_not_available (self , mock_session_class ) -> None :
63+ @patch ('src.utils.model_client.requests.get ' )
64+ def test_model_not_available (self , mock_get ) -> None :
6665 """Test when model is not available"""
67- mock_session = MagicMock ()
6866 mock_response = MagicMock ()
6967 mock_response .json .return_value = {
7068 "models" : [{"name" : "other:model" }]
7169 }
72- mock_session . get .return_value = mock_response
73- mock_session_class .return_value = mock_session
70+ mock_response . raise_for_status .return_value = None
71+ mock_get .return_value = mock_response
7472
7573 client = OllamaClient ()
7674 assert client .is_model_available () is False
0 commit comments