Skip to content

Commit

Permalink
Fix invalid client version test
Browse files Browse the repository at this point in the history
  • Loading branch information
natthan-pigoux committed Sep 23, 2024
1 parent 14991d8 commit 963941f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions diracx-routers/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 963941f

Please sign in to comment.