Add household price proxies with explicit assumptions to stove API
This commit is contained in:
@@ -167,12 +167,22 @@ def test_request_schema_is_the_contract_the_openapi_is_built_from():
|
||||
assert schema["additionalProperties"] is False
|
||||
assert set(schema["properties"]) == {"stove"}
|
||||
stove = schema["$defs"][schema["properties"]["stove"]["$ref"].split("/")[-1]]
|
||||
assert set(stove["properties"]) == {"kind", "bricks", "mass_kg", "materials", "context", "region", "zone"}
|
||||
assert set(stove["properties"]) == {"kind", "bricks", "mass_kg", "materials", "context", "region", "zone", "bucket_volume_l"}
|
||||
assert set(stove["required"]) == {"kind", "bricks", "region"}
|
||||
assert stove["properties"]["bricks"]["$ref"].endswith("/Bricks")
|
||||
assert len(stove["properties"]["materials"]["anyOf"]) == 2, "ведомость необязательна"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [0, 31, True, "10", float("nan")])
|
||||
def test_bucket_volume_rejects_invalid_defaults(value):
|
||||
with pytest.raises(ValidationError):
|
||||
c.StoveRequest.model_validate(_stove(bucket_volume_l=value))
|
||||
|
||||
|
||||
def test_bucket_volume_accepts_explicit_household_measure():
|
||||
assert c.StoveRequest.model_validate(_stove(bucket_volume_l=12)).stove.bucket_volume_l == 12
|
||||
|
||||
|
||||
def test_answer_without_zone_has_no_zone_key_at_all():
|
||||
out = c.StoveAnswer.model_validate(_answer()).model_dump(mode="json")
|
||||
assert "zone" not in out["basis"]
|
||||
|
||||
Reference in New Issue
Block a user