From 963941fd76dbecced09e7c8e3b997b7e64681908 Mon Sep 17 00:00:00 2001 From: natthan-pigoux Date: Mon, 23 Sep 2024 14:55:38 +0200 Subject: [PATCH] Fix invalid client version test --- diracx-routers/tests/test_generic.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diracx-routers/tests/test_generic.py b/diracx-routers/tests/test_generic.py index 3b4e6bbbe..30481cadd 100644 --- a/diracx-routers/tests/test_generic.py +++ b/diracx-routers/tests/test_generic.py @@ -2,7 +2,7 @@ import pytest from fastapi import HTTPException -from packaging.version import InvalidVersion, Version, parse +from packaging.version import Version, parse from diracx.routers.version import DIRACX_MIN_CLIENT_VERSION @@ -62,11 +62,12 @@ def test_min_client_version_lower_than_expected(test_client): with pytest.raises(HTTPException) as response: test_client.get("/", headers={"DiracX-Client-Version": lower_version_than_min}) assert response.value.status_code == HTTPStatus.UPGRADE_REQUIRED - assert "not recent enough" in response.value.detail + assert str(min_client_version) in response.value.detail def test_invalid_client_version(test_client, caplog: pytest.LogCaptureFixture): invalid_version = "invalid.version" - with pytest.raises(InvalidVersion) as exec_iv: + with pytest.raises(HTTPException) as response: test_client.get("/", headers={"DiracX-Client-Version": invalid_version}) - assert f"Invalid version: '{invalid_version}'" in str(exec_iv.value) + assert response.value.status_code == 400 + assert invalid_version in response.value.detail