Skip to content

Commit

Permalink
- fixed tests failing when OPENAI_API_KEY isn't defined;
Browse files Browse the repository at this point in the history
  • Loading branch information
jaltmayerpizzorno committed Aug 3, 2024
1 parent a17dbeb commit e66ecfe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/test_coverup_25.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def test_parse_args_with_source_files(tmp_path):
tests_dir.mkdir()
source_dir = tmp_path / "source"
source_dir.mkdir()
args = parse_args([str(source_file), '--tests-dir', str(tests_dir), '--source-dir', str(source_dir)])
args = parse_args([str(source_file), '--tests-dir', str(tests_dir), '--source-dir', str(source_dir), '--model', 'gpt-4'])
assert args.source_files[0] == source_file.resolve()
9 changes: 5 additions & 4 deletions tests/test_llm_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def __init__(self):
'content': 'test prompt'}]

with patch("litellm.acreate",
new=AsyncMock(side_effect=openai.AuthenticationError("Authentication failed", response=MockResponse(), body=''))):
chatter = llm.Chatter(model="gpt-4")
new=AsyncMock(side_effect=openai.AuthenticationError("Authentication failed", response=MockResponse(), body=''))):
with patch.object(llm.Chatter, '_validate_model'):
chatter = llm.Chatter(model="gpt-4")

with pytest.raises(openai.AuthenticationError):
await chatter.chat(messages)
with pytest.raises(openai.AuthenticationError):
await chatter.chat(messages)
4 changes: 2 additions & 2 deletions tests/test_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_gpt4_v1_relative_file_name(tmp_path, monkeypatch):
(tmp_path / "tests").mkdir(parents=True)

from coverup.coverup import parse_args
args = parse_args(["--source", "lib/ansible", "--tests", "tests"])
args = parse_args(["--source", "lib/ansible", "--tests", "tests", "--model", "gpt-4o"])

from coverup.segment import CodeSegment
segment = CodeSegment(
Expand All @@ -45,7 +45,7 @@ def test_claude_relative_file_name(tmp_path, monkeypatch):
(tmp_path / "tests").mkdir(parents=True)

from coverup.coverup import parse_args
args = parse_args(["--source", "lib/ansible", "--tests", "tests"])
args = parse_args(["--source", "lib/ansible", "--tests", "tests", "--model", "anthropic/claude-3-sonnet-20240229"])

from coverup.segment import CodeSegment
segment = CodeSegment(
Expand Down

0 comments on commit e66ecfe

Please sign in to comment.