mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
validate plans api response as pydantic basemodel object 🟩
This commit is contained in:
parent
e67604a4a3
commit
06567c2844
1 changed files with 32 additions and 0 deletions
|
|
@ -105,3 +105,35 @@ def plans_response(plans_raw_data: dict[str, Any]) -> PlansListResponse:
|
|||
def test_plans_list_model_validate_does_not_raise(plans_raw_data: dict[str, Any]) -> None:
|
||||
# act
|
||||
PlansListResponse.model_validate(plans_raw_data)
|
||||
|
||||
|
||||
def test_plans_list_count(plans_response: PlansListResponse) -> None:
|
||||
# assert
|
||||
assert len(plans_response.plans) == 1
|
||||
|
||||
|
||||
def test_plans_list_first_plan_id(plans_response: PlansListResponse) -> None:
|
||||
# assert
|
||||
assert plans_response.plans[0].id == "9f9889ff-793e-4e9a-a6f0-e22f5b0f5365"
|
||||
|
||||
|
||||
def test_plans_list_paging_page(plans_response: PlansListResponse) -> None:
|
||||
# assert
|
||||
assert plans_response.paging.page == 1
|
||||
|
||||
|
||||
def test_plans_list_paging_next_page_is_false(plans_response: PlansListResponse) -> None:
|
||||
# assert
|
||||
assert plans_response.paging.next_page is False
|
||||
|
||||
|
||||
def test_plans_list_paging_count(plans_response: PlansListResponse) -> None:
|
||||
# assert
|
||||
assert plans_response.paging.count == 1
|
||||
|
||||
|
||||
def test_plans_list_unknown_keys_ignored(plans_raw_data: dict[str, Any]) -> None:
|
||||
# arrange
|
||||
data_with_extra = {**plans_raw_data, "unknown_future_field": "whatever"}
|
||||
# act
|
||||
PlansListResponse.model_validate(data_with_extra)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue