validate plans api response as pydantic basemodel object 🟩

This commit is contained in:
Daniel Roth 2026-05-07 12:25:06 +00:00
parent e67604a4a3
commit 06567c2844

View file

@ -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)