| import pytest |
| from pydantic import ValidationError |
|
|
|
|
| def test_route_response_valid(): |
| from core.schemas import RouteResponse |
| r = RouteResponse( |
| sectors=["WASH", "Food Security"], |
| lens=["Humanitarian Conditions"], |
| type=[], |
| ) |
| assert r.sectors == ["WASH", "Food Security"] |
| assert r.lens == ["Humanitarian Conditions"] |
| assert r.type == [] |
|
|
|
|
| def test_route_response_empty_sectors_ok(): |
| from core.schemas import RouteResponse |
| r = RouteResponse(sectors=[], lens=[], type=[]) |
| assert r.sectors == [] |
|
|
|
|
| def test_bind_response_valid(): |
| from core.schemas import BindResponse |
| b = BindResponse( |
| indicator_id="rcsi", |
| variables=["food_access_cope"], |
| measurable="PROXY", |
| reasons="Collects coping strategy frequency but not quantity; ordinal not continuous.", |
| result_ids=["rcsi_score"], |
| ) |
| assert b.measurable == "PROXY" |
| assert b.result_ids == ["rcsi_score"] |
|
|
|
|
| def test_bind_response_result_ids_default_empty(): |
| from core.schemas import BindResponse |
| b = BindResponse( |
| indicator_id="fcs", |
| variables=[], |
| measurable="NOT_MEASURABLE", |
| reasons="No dietary-recall question present in instrument.", |
| ) |
| assert b.result_ids == [] |
|
|
|
|
| def test_bind_response_rejects_invalid_verdict(): |
| from core.schemas import BindResponse |
| with pytest.raises(ValidationError): |
| BindResponse( |
| indicator_id="fcs", |
| variables=[], |
| measurable="MAYBE", |
| reasons="test", |
| ) |
|
|
|
|
| def test_pick_vars_response_valid(): |
| from core.schemas import PickVarsResponse |
| r = PickVarsResponse(candidate_variables=["food_cope_1", "food_cope_2"]) |
| assert r.candidate_variables == ["food_cope_1", "food_cope_2"] |
|
|
|
|
| def test_pick_vars_response_empty_vars(): |
| from core.schemas import PickVarsResponse |
| r = PickVarsResponse(candidate_variables=[]) |
| assert r.candidate_variables == [] |
|
|