88from pathlib import Path
99import subprocess
1010import sys
11+ from unittest .mock import patch , Mock
1112
1213import pytest
1314# Add src directory to path to import from local source
@@ -79,6 +80,19 @@ def no_mount_microBot(self):
7980 yield bot
8081 del bot
8182
83+ @pytest .fixture (scope = "function" )
84+ def anthropic_microBot (self ):
85+ with patch ('microbots.llm.anthropic_api.endpoint' , 'https://api.anthropic.com' ), \
86+ patch ('microbots.llm.anthropic_api.deployment_name' , 'claude-sonnet-4' ), \
87+ patch ('microbots.llm.anthropic_api.api_key' , 'test-api-key' ), \
88+ patch ('microbots.llm.anthropic_api.Anthropic' ):
89+ bot = MicroBot (
90+ model = "anthropic/claude-sonnet-4" ,
91+ system_prompt = SYSTEM_PROMPT ,
92+ )
93+ yield bot
94+ del bot
95+
8296 def test_microbot_ro_mount (self , ro_microBot , test_repo : Path ):
8397 assert test_repo is not None
8498
@@ -100,6 +114,15 @@ def test_microbot_overlay_teardown(self, ro_microBot, caplog):
100114
101115 assert "Failed to remove working directory" not in caplog .text
102116
117+ def test_microbot_anthropic_initialization (self , anthropic_microBot ):
118+ """Test that MicroBot correctly initializes with Anthropic model provider."""
119+ assert anthropic_microBot is not None
120+ assert anthropic_microBot .model_provider == "anthropic"
121+ assert anthropic_microBot .deployment_name == "claude-sonnet-4"
122+ assert anthropic_microBot .llm is not None
123+ from microbots .llm .anthropic_api import AnthropicApi
124+ assert isinstance (anthropic_microBot .llm , AnthropicApi )
125+
103126 def test_microbot_2bot_combo (self , log_file_path , test_repo , issue_1 ):
104127 assert test_repo is not None
105128 assert log_file_path is not None
@@ -229,6 +252,28 @@ def test_incorrect_model_format(self, test_repo):
229252 folder_to_mount = test_repo_mount_ro ,
230253 )
231254
255+ def test_microbot_anthropic_with_mount (self , test_repo ):
256+ """Test that MicroBot with Anthropic provider works with mounted folders."""
257+ assert test_repo is not None
258+
259+ test_repo_mount_ro = Mount (
260+ str (test_repo ), f"{ DOCKER_WORKING_DIR } /{ test_repo .name } " , PermissionLabels .READ_ONLY
261+ )
262+ with patch ('microbots.llm.anthropic_api.endpoint' , 'https://api.anthropic.com' ), \
263+ patch ('microbots.llm.anthropic_api.deployment_name' , 'claude-sonnet-4' ), \
264+ patch ('microbots.llm.anthropic_api.api_key' , 'test-api-key' ), \
265+ patch ('microbots.llm.anthropic_api.Anthropic' ):
266+ bot = MicroBot (
267+ model = "anthropic/claude-sonnet-4" ,
268+ system_prompt = SYSTEM_PROMPT ,
269+ folder_to_mount = test_repo_mount_ro ,
270+ )
271+ assert bot is not None
272+ assert bot .model_provider == "anthropic"
273+ from microbots .llm .anthropic_api import AnthropicApi
274+ assert isinstance (bot .llm , AnthropicApi )
275+ del bot
276+
232277 def test_max_iterations_exceeded (self , no_mount_microBot , monkeypatch ):
233278 assert no_mount_microBot is not None
234279
0 commit comments