from __future__ import annotations from ww_shared import AppError, ErrorBody, ErrorCode, ErrorEnvelope def test_app_error_maps_to_http_status() -> None: assert AppError(ErrorCode.NOT_FOUND, "x").http_status == 404 assert AppError(ErrorCode.CONFLICT_UNRESOLVED, "x").http_status == 409 def test_envelope_serializes_with_request_id() -> None: env = ErrorEnvelope( error=ErrorBody(code=ErrorCode.VALIDATION, message="bad", request_id="rid-1") ) dumped = env.model_dump() assert dumped["error"]["code"] == "VALIDATION" assert dumped["error"]["request_id"] == "rid-1"