Skip to content

Commit 24ca884

Browse files
authored
Merge pull request #7 from netdevops/claude/fix-test-import-error-cJ6yo
Fix import error in test configuration
2 parents 16505b1 + 484f3ec commit 24ca884

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-latest, macos-latest, windows-latest]
15+
os: [ubuntu-latest, macos-latest]
1616
python-version: ["3.10", "3.11", "3.12"]
1717

1818
steps:
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Install dependencies
4141
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
42-
run: poetry install --no-interaction --no-root --with dev
42+
run: poetry install --no-interaction --no-root --with dev,anthropic,chatgpt,ollama
4343

4444
- name: Install project
4545
run: poetry install --no-interaction
@@ -79,7 +79,7 @@ jobs:
7979
uses: snok/install-poetry@v1
8080

8181
- name: Install dependencies
82-
run: poetry install --no-interaction --with dev
82+
run: poetry install --no-interaction --with dev,anthropic,chatgpt,ollama
8383

8484
- name: Run pylint
8585
run: poetry run pylint hier_config_gpt
@@ -100,7 +100,7 @@ jobs:
100100
uses: snok/install-poetry@v1
101101

102102
- name: Install dependencies
103-
run: poetry install --no-interaction --with dev
103+
run: poetry install --no-interaction --with dev,anthropic,chatgpt,ollama
104104

105105
- name: Build documentation
106106
run: poetry run mkdocs build --strict

tests/test_clients.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from unittest.mock import MagicMock, patch
22

3+
import pytest
4+
35
from hier_config_gpt.clients.anthropic import ClaudeGPTClient
46
from hier_config_gpt.clients.models import GPTPlanResponse
57
from hier_config_gpt.clients.ollama import OllamaGPTClient
@@ -20,7 +22,7 @@ def test_init(self, mock_openai_class):
2022
assert client.temp == 0
2123

2224
# Check constructor was called
23-
mock_openai_class.assert_called_once_with(api_key="test-key")
25+
mock_openai_class.assert_called_once_with(api_key="test-key", timeout=60.0)
2426

2527
@patch("hier_config_gpt.clients.openai.OpenAI")
2628
def test_chat(self, mock_openai_class):
@@ -56,7 +58,7 @@ def test_chat(self, mock_openai_class):
5658

5759
# Verify mock was called with correct parameters
5860
mock_completions.create.assert_called_once_with(
59-
model="gpt-4",
61+
model="gpt-4o",
6062
messages=[{"role": "user", "content": "Test prompt"}],
6163
max_tokens=1000,
6264
temperature=0,
@@ -96,7 +98,7 @@ def test_generate_plan(self, mock_openai_class):
9698

9799
# Verify mock was called with correct parameters
98100
mock_completions.create.assert_called_once_with(
99-
model="gpt-4",
101+
model="gpt-4o",
100102
messages=[{"role": "user", "content": "Test prompt"}],
101103
max_tokens=1000,
102104
temperature=0,
@@ -145,7 +147,7 @@ def test_init(self, mock_anthropic_class):
145147
assert client.temp == 0
146148

147149
# Check constructor was called
148-
mock_anthropic_class.assert_called_once_with(api_key="test-key")
150+
mock_anthropic_class.assert_called_once_with(api_key="test-key", timeout=60.0)
149151

150152
@patch("hier_config_gpt.clients.anthropic.Anthropic")
151153
def test_chat(self, mock_anthropic_class):
@@ -176,7 +178,7 @@ def test_chat(self, mock_anthropic_class):
176178

177179
# Verify mock was called with correct parameters
178180
mock_messages.create.assert_called_once_with(
179-
model="claude-3-opus-20240229",
181+
model="claude-3-5-sonnet-20241022",
180182
messages=[{"role": "user", "content": "Test prompt"}],
181183
max_tokens=1024,
182184
temperature=0,
@@ -211,7 +213,7 @@ def test_generate_plan(self, mock_anthropic_class):
211213

212214
# Verify mock was called with correct parameters
213215
mock_messages.create.assert_called_once_with(
214-
model="claude-3-opus-20240229",
216+
model="claude-3-5-sonnet-20241022",
215217
messages=[{"role": "user", "content": "Test prompt"}],
216218
max_tokens=1024,
217219
temperature=0,
@@ -248,7 +250,9 @@ def test_init(self, mock_ollama):
248250
assert client.temp == 0
249251

250252
# Check client was created correctly
251-
mock_ollama.Client.assert_called_once_with(host="http://localhost:12345")
253+
mock_ollama.Client.assert_called_once_with(
254+
host="http://localhost:12345", timeout=60.0
255+
)
252256

253257
@patch("hier_config_gpt.clients.ollama.ollama")
254258
def test_chat(self, mock_ollama):
@@ -271,9 +275,9 @@ def test_chat(self, mock_ollama):
271275

272276
# Verify mock was called with correct parameters
273277
mock_client.chat.assert_called_once_with(
274-
model="llama3",
278+
model="llama3.2",
275279
messages=[{"role": "user", "content": "Test prompt"}],
276-
options={"num_predict": 1024, "temperature": 0},
280+
options={"num_predict": 1024, "temperature": 0.0},
277281
)
278282

279283
@patch("hier_config_gpt.clients.ollama.ollama")
@@ -299,9 +303,9 @@ def test_generate_plan(self, mock_ollama):
299303

300304
# Verify mock was called with correct parameters
301305
mock_client.chat.assert_called_once_with(
302-
model="llama3",
306+
model="llama3.2",
303307
messages=[{"role": "user", "content": "Test prompt"}],
304-
options={"num_predict": 1024, "temperature": 0},
308+
options={"num_predict": 1024, "temperature": 0.0},
305309
)
306310

307311
def test_process_response(self):
@@ -344,10 +348,7 @@ def test_generate_plan_exception_handling(self, mock_ollama):
344348

345349
mock_ollama.Client.return_value = mock_client
346350

347-
# Create client and call method
351+
# Create client and verify exception is raised after retries
348352
client = OllamaGPTClient()
349-
result = client.generate_plan("Test prompt")
350-
351-
# Verify expectations
352-
assert len(result.plan) == 1
353-
assert "Error generating plan: Connection error" in result.plan[0]
353+
with pytest.raises(Exception, match="Connection error"):
354+
client.generate_plan("Test prompt")

0 commit comments

Comments
 (0)