@@ -250,6 +250,24 @@ def groq_with_logfire_config(groq_config):
250250 return config
251251
252252
253+ @pytest .fixture
254+ def openai_with_model_config ():
255+ """Config with OpenAI and a custom model specified."""
256+ return {
257+ "openai" : {
258+ "api_key" : "test-openai-key" ,
259+ "model" : "gpt-4.1-mini" ,
260+ },
261+ "agents" : [
262+ {
263+ "name" : "test_agent" ,
264+ "instructions" : "You are a test agent." ,
265+ "specialization" : "Testing" ,
266+ }
267+ ],
268+ }
269+
270+
253271@pytest .fixture
254272def invalid_logfire_config_missing_key (base_config ):
255273 """Config with logfire section missing api_key."""
@@ -1855,3 +1873,44 @@ def test_create_groq_without_logfire(
18551873 mock_routing_service .assert_called_once ()
18561874 mock_query_service .assert_called_once ()
18571875 assert result == mock_query_instance
1876+
1877+ @patch ("solana_agent.factories.agent_factory.MongoDBAdapter" )
1878+ @patch ("solana_agent.factories.agent_factory.OpenAIAdapter" )
1879+ @patch ("solana_agent.factories.agent_factory.AgentService" )
1880+ @patch ("solana_agent.factories.agent_factory.RoutingService" )
1881+ @patch ("solana_agent.factories.agent_factory.QueryService" )
1882+ def test_create_openai_with_model (
1883+ self ,
1884+ mock_query_service ,
1885+ mock_routing_service ,
1886+ mock_agent_service ,
1887+ mock_openai_adapter ,
1888+ mock_mongo_adapter ,
1889+ openai_with_model_config ,
1890+ ):
1891+ """Test creating services with OpenAI and a custom model specified."""
1892+ # Setup mocks
1893+ mock_openai_instance = MagicMock ()
1894+ mock_openai_adapter .return_value = mock_openai_instance
1895+ mock_agent_instance = MagicMock ()
1896+ mock_agent_service .return_value = mock_agent_instance
1897+ mock_agent_instance .tool_registry .list_all_tools .return_value = []
1898+ mock_routing_instance = MagicMock ()
1899+ mock_routing_service .return_value = mock_routing_instance
1900+ mock_query_instance = MagicMock ()
1901+ mock_query_service .return_value = mock_query_instance
1902+
1903+ # Call the factory
1904+ result = SolanaAgentFactory .create_from_config (openai_with_model_config )
1905+
1906+ # Verify OpenAIAdapter was called with OpenAI config and custom model
1907+ mock_openai_adapter .assert_called_once_with (
1908+ api_key = "test-openai-key" ,
1909+ base_url = None ,
1910+ model = "gpt-4.1-mini" ,
1911+ )
1912+ # Verify other services were called
1913+ mock_agent_service .assert_called_once ()
1914+ mock_routing_service .assert_called_once ()
1915+ mock_query_service .assert_called_once ()
1916+ assert result == mock_query_instance
0 commit comments