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
8 changes: 4 additions & 4 deletions tests/unit/app/endpoints/test_authorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ async def test_authorized_dependency_unauthorized() -> None:
with pytest.raises(HTTPException) as exc_info:
extract_user_token(headers_no_auth)
assert exc_info.value.status_code == 401
assert exc_info.value.detail["response"] == ( # type: ignore
assert exc_info.value.detail["response"] == ( # type: ignore[index]
"Missing or invalid credentials provided by client"
)
assert exc_info.value.detail["cause"] == ( # type: ignore
assert exc_info.value.detail["cause"] == ( # type: ignore[index]
"No Authorization header found"
)

headers_invalid_auth = Headers({"Authorization": "InvalidFormat"})
with pytest.raises(HTTPException) as exc_info:
extract_user_token(headers_invalid_auth)
assert exc_info.value.status_code == 401
assert exc_info.value.detail["response"] == ( # type: ignore
assert exc_info.value.detail["response"] == ( # type: ignore[index]
"Missing or invalid credentials provided by client"
)
assert exc_info.value.detail["cause"] == ( # type: ignore
assert exc_info.value.detail["cause"] == ( # type: ignore[index]
"No token found in Authorization header"
)
4 changes: 2 additions & 2 deletions tests/unit/app/endpoints/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ async def test_config_endpoint_handler_configuration_not_loaded(

detail = exc_info.value.detail
assert isinstance(detail, dict)
assert detail["response"] == "Configuration is not loaded" # type: ignore
assert detail["cause"] == ( # type: ignore
assert detail["response"] == "Configuration is not loaded" # type: ignore[index]
assert detail["cause"] == ( # type: ignore[index]
"Lightspeed Stack configuration has not been initialized."
)

Expand Down
14 changes: 7 additions & 7 deletions tests/unit/utils/test_shields.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async def test_raises_http_exception_when_shield_model_not_found(
await run_shield_moderation(mock_client, "test input", "/test-endpoint")

assert exc_info.value.status_code == status.HTTP_404_NOT_FOUND
assert "missing-model" in exc_info.value.detail["cause"] # type: ignore
assert "missing-model" in exc_info.value.detail["cause"] # type: ignore[index]

@pytest.mark.asyncio
async def test_raises_http_exception_when_shield_has_no_provider_resource_id(
Expand Down Expand Up @@ -352,8 +352,8 @@ async def test_shield_ids_raises_404_when_no_shields_found(
)

assert exc_info.value.status_code == status.HTTP_404_NOT_FOUND
assert "Shield" in exc_info.value.detail["response"] # type: ignore
assert "typo-shield" in exc_info.value.detail["cause"] # type: ignore
assert "Shield" in exc_info.value.detail["response"] # type: ignore[index]
assert "typo-shield" in exc_info.value.detail["cause"] # type: ignore[index]

@pytest.mark.asyncio
async def test_shield_ids_filters_to_specific_shield(
Expand Down Expand Up @@ -577,8 +577,8 @@ async def test_raises_404_when_requested_shield_not_configured(
)

assert exc_info.value.status_code == status.HTTP_404_NOT_FOUND
assert "Shield" in exc_info.value.detail["response"] # type: ignore
assert "missing-shield" in exc_info.value.detail["cause"] # type: ignore
assert "Shield" in exc_info.value.detail["response"] # type: ignore[index]
assert "missing-shield" in exc_info.value.detail["cause"] # type: ignore[index]

@pytest.mark.asyncio
async def test_raises_404_when_multiple_requested_shields_not_configured(
Expand All @@ -594,8 +594,8 @@ async def test_raises_404_when_multiple_requested_shields_not_configured(
)

assert exc_info.value.status_code == status.HTTP_404_NOT_FOUND
assert "Shields" in exc_info.value.detail["response"] # type: ignore
cause = exc_info.value.detail["cause"] # type: ignore
assert "Shields" in exc_info.value.detail["response"] # type: ignore[index]
cause = exc_info.value.detail["cause"] # type: ignore[index]
assert "missing-1" in cause
assert "missing-2" in cause

Expand Down
Loading