Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -29,28 +29,20 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached Poetry dependencies
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --with dev

- name: Run tests
run: |
# Verify test_responses.yml exists
test -f tests/test_responses.yml || (echo "tests/test_responses.yml not found" && exit 1)
# test -f tests/test_responses.yml || (echo "tests/test_responses.yml not found" && exit 1)
poetry run pytest tests/ -v

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -63,24 +55,16 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached Poetry dependencies
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-lint-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --with dev

- name: Check formatting
run: |
poetry run black --check .
poetry run isort --check .

- name: Type checking
run: poetry run mypy src/

- name: Lint
run: poetry run ruff check .
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mockllm"
version = "0.1.0"
version = "0.0.5"
description = "A mock server that mimics OpenAI and Anthropic API formats for testing"
authors = ["Luke Hinds <[email protected]>"]
license = "Apache-2.0"
Expand Down
6 changes: 0 additions & 6 deletions test_responses.yml

This file was deleted.

22 changes: 0 additions & 22 deletions tests/conftest.py

This file was deleted.

24 changes: 23 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from unittest.mock import mock_open, patch

import pytest
from fastapi.testclient import TestClient

from mockllm.server import app
# Move MOCK_YAML_CONTENT definition to top
MOCK_YAML_CONTENT = """
responses:
default: "Hello, this is a mock response."
"""

# Create a patch for ResponseConfig before importing server
with patch("builtins.open", mock_open(read_data=MOCK_YAML_CONTENT)), patch(
"os.path.exists", return_value=True
), patch("mockllm.config.ResponseConfig.load_responses"):
from mockllm.server import app

client = TestClient(app)


@pytest.fixture(autouse=True)
def mock_responses_file():
# Update the fixture to also patch ResponseConfig.load_responses
with patch("builtins.open", mock_open(read_data=MOCK_YAML_CONTENT)), patch(
"os.path.exists", return_value=True
), patch("mockllm.config.ResponseConfig.load_responses"):
yield


def test_openai_chat_completion():
response = client.post(
"/v1/chat/completions",
Expand Down