Skip to content

Commit 460295d

Browse files
authored
Response file (#8)
1 parent 6a24902 commit 460295d

File tree

5 files changed

+31
-53
lines changed

5 files changed

+31
-53
lines changed

.github/workflows/ci.yml

+7-23
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v4
19-
19+
2020
- name: Set up Python ${{ matrix.python-version }}
2121
uses: actions/setup-python@v5
2222
with:
@@ -29,28 +29,20 @@ jobs:
2929
virtualenvs-create: true
3030
virtualenvs-in-project: true
3131

32-
- name: Load cached Poetry dependencies
33-
id: cached-poetry-dependencies
34-
uses: actions/cache@v4
35-
with:
36-
path: .venv
37-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
38-
3932
- name: Install dependencies
40-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
4133
run: poetry install --with dev
42-
34+
4335
- name: Run tests
4436
run: |
4537
# Verify test_responses.yml exists
46-
test -f tests/test_responses.yml || (echo "tests/test_responses.yml not found" && exit 1)
38+
# test -f tests/test_responses.yml || (echo "tests/test_responses.yml not found" && exit 1)
4739
poetry run pytest tests/ -v
4840
4941
lint:
5042
runs-on: ubuntu-latest
5143
steps:
5244
- uses: actions/checkout@v4
53-
45+
5446
- name: Set up Python
5547
uses: actions/setup-python@v5
5648
with:
@@ -63,24 +55,16 @@ jobs:
6355
virtualenvs-create: true
6456
virtualenvs-in-project: true
6557

66-
- name: Load cached Poetry dependencies
67-
id: cached-poetry-dependencies
68-
uses: actions/cache@v4
69-
with:
70-
path: .venv
71-
key: venv-${{ runner.os }}-lint-${{ hashFiles('**/poetry.lock') }}
72-
7358
- name: Install dependencies
74-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
7559
run: poetry install --with dev
76-
60+
7761
- name: Check formatting
7862
run: |
7963
poetry run black --check .
8064
poetry run isort --check .
81-
65+
8266
- name: Type checking
8367
run: poetry run mypy src/
84-
68+
8569
- name: Lint
8670
run: poetry run ruff check .

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mockllm"
3-
version = "0.1.0"
3+
version = "0.0.5"
44
description = "A mock server that mimics OpenAI and Anthropic API formats for testing"
55
authors = ["Luke Hinds <[email protected]>"]
66
license = "Apache-2.0"

test_responses.yml

-6
This file was deleted.

tests/conftest.py

-22
This file was deleted.

tests/test_server.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1+
from unittest.mock import mock_open, patch
2+
3+
import pytest
14
from fastapi.testclient import TestClient
25

3-
from mockllm.server import app
6+
# Move MOCK_YAML_CONTENT definition to top
7+
MOCK_YAML_CONTENT = """
8+
responses:
9+
default: "Hello, this is a mock response."
10+
"""
11+
12+
# Create a patch for ResponseConfig before importing server
13+
with patch("builtins.open", mock_open(read_data=MOCK_YAML_CONTENT)), patch(
14+
"os.path.exists", return_value=True
15+
), patch("mockllm.config.ResponseConfig.load_responses"):
16+
from mockllm.server import app
417

518
client = TestClient(app)
619

720

21+
@pytest.fixture(autouse=True)
22+
def mock_responses_file():
23+
# Update the fixture to also patch ResponseConfig.load_responses
24+
with patch("builtins.open", mock_open(read_data=MOCK_YAML_CONTENT)), patch(
25+
"os.path.exists", return_value=True
26+
), patch("mockllm.config.ResponseConfig.load_responses"):
27+
yield
28+
29+
830
def test_openai_chat_completion():
931
response = client.post(
1032
"/v1/chat/completions",

0 commit comments

Comments
 (0)