Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Extralit_extralit /extralit-server /tests /unit /test_utils.py
| from typing import Any | |
| import pytest | |
| from fastapi import HTTPException | |
| from pydantic import BaseModel, Field | |
| from extralit_server.utils import parse_query_param | |
| def test_parse_query_param(config: dict[str, Any], params: list[str], expected: dict[str, set[str]]) -> None: | |
| parse_function = parse_query_param(name="unit-test", **config) | |
| result = parse_function(param_values=params) | |
| assert result == expected | |
| def test_parse_query_param_with_base_model() -> None: | |
| class Params(BaseModel): | |
| keys: list[str] = Field(..., alias="keys") | |
| my_other_key_with_values: list[str] = Field(..., alias="key5") | |
| parse_function = parse_query_param(name="unit-test", model=Params) | |
| result = parse_function(param_values=["key1", "key2", "key3,key4", "key5:value1,value2,value3"]) | |
| assert sorted(result.keys) == ["key1", "key2", "key3", "key4"] | |
| assert sorted(result.my_other_key_with_values) == ["value1", "value2", "value3"] | |
| def test_parse_query_param_raises_http_exception(config: dict[str, Any], params: list[str], expected_msg: str) -> None: | |
| parse_function = parse_query_param(name="unit-test", **config) | |
| with pytest.raises(HTTPException, match="") as exc_info: | |
| parse_function(param_values=params) | |
| assert exc_info.value.status_code == 422 | |
| assert exc_info.value.detail == expected_msg | |
Xet Storage Details
- Size:
- 3.38 kB
- Xet hash:
- 8a6b3175cd3e71c87325e7d1d404fba3d4021e5683bbd858a4d5bcbcacdbab34
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.