Skip to content

Commit

Permalink
final: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmesel committed Jun 12, 2024
1 parent d107368 commit 941ca28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion etc/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e
cd /app/src/
poetry install --only dev
poetry run alembic upgrade head
exec poetry run pytest --cov=. --cov-config=.coveragerc .
exec poetry run pytest --cov=. --cov-config=.coveragerc . -vvv
15 changes: 13 additions & 2 deletions src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,21 @@ def get_session_override():

settings = tomllib.loads(Path("/app/src/tests/fixtures/multi_model.toml").read_text())

blob_model = settings["endpoint"][0]

mocker.patch("main.Settings.PROJECT_CONFIG", return_value=settings, new_callable=mocker.PropertyMock)

with TestClient(app) as client:
app.dependency_overrides[get_session] = get_session_override
monkeypatch.setenv("PROJECT_CONFIG", "/app/src/tests/fixtures/multi_model.toml")

main_app = app

add_model_router(
main_app,
blob_model["model_class_path"],
blob_model.get("path")
)
with TestClient(main_app) as client:
main_app.dependency_overrides[get_session] = get_session_override
yield client

@pytest.fixture
Expand Down
7 changes: 0 additions & 7 deletions src/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ def test_customized_openai_chat_completion_response_stream_false(client, llm_moc
assert llm_mock_openai_router.called
assert response.json()["choices"][0]["message"]["role"] == "assistant"


def test_multiple_models_load_on_setting_override(client_with_settings_override):
response = client_with_settings_override.get("/openapi.json")
assert response.status_code == 200
assert "/lerolero/chat/{chat_id}" in list(response.json().get("paths").keys())
assert "/lerolero/ask" in list(response.json().get("paths").keys())

def test_multiple_models_are_available_on_model_listing_for_webui(client_with_settings_override):
response = client_with_settings_override.get("/openai/models")
assert response.status_code == 200
Expand Down

0 comments on commit 941ca28

Please sign in to comment.