From e78e4ff9c3f7852cb47429a852bfb2d0ec7e6dcc Mon Sep 17 00:00:00 2001 From: Julian Wiesler Date: Wed, 10 Jan 2024 17:07:26 +0100 Subject: [PATCH] Add tests for api version checking --- tests/test_clients.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_clients.py b/tests/test_clients.py index fe895d2..06546f3 100644 --- a/tests/test_clients.py +++ b/tests/test_clients.py @@ -13,6 +13,32 @@ from tests.common import model_name, sync_client, async_client +def test_api_version_mismatch_client(httpserver: HTTPServer): + httpserver.expect_request("/version").respond_with_data("0.0.0") + + with pytest.raises(RuntimeError): + Client(host=httpserver.url_for(""), token="AA_TOKEN") + + +async def test_api_version_mismatch_async_client(httpserver: HTTPServer): + httpserver.expect_request("/version").respond_with_data("0.0.0") + + with pytest.raises(RuntimeError): + async with AsyncClient(host=httpserver.url_for(""), token="AA_TOKEN"): + pass + + +def test_api_version_correct_client(httpserver: HTTPServer): + httpserver.expect_request("/version").respond_with_data(MIN_API_VERSION) + Client(host=httpserver.url_for(""), token="AA_TOKEN") + + +async def test_api_version_correct_async_client(httpserver: HTTPServer): + httpserver.expect_request("/version").respond_with_data(MIN_API_VERSION) + async with AsyncClient(host=httpserver.url_for(""), token="AA_TOKEN"): + pass + + @pytest.mark.system_test async def test_can_use_async_client_without_context_manager(model_name: str): request = CompletionRequest(