File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,9 +45,9 @@ class PingResponse(BaseModel):
4545class Error (BaseModel ):
4646 code : str
4747 message : str
48- translation_key : str
49- translation_placeholders : dict [str , str ]
50- translation_domain : str
48+ translation_key : Optional [ str ] = None
49+ translation_placeholders : Optional [ dict [str , str ]] = None
50+ translation_domain : Optional [ str ] = None
5151
5252
5353class ErrorResponse (BaseModel ):
Original file line number Diff line number Diff line change 2323 UnauthorizedError ,
2424 UnexpectedStatusCodeError ,
2525)
26+ from homeassistant_api .models .websocket import Error
2627from homeassistant_api .processing import Processing
2728from homeassistant_api .utils import prepare_entity_id
2829from homeassistant_api .websocket import WebsocketClient
@@ -220,3 +221,12 @@ def test_exception_unexpected_status_code() -> None:
220221def test_unkown_scheme () -> None :
221222 with pytest .raises (ValueError ):
222223 Client ("ftp://example.com" , "token" )
224+
225+
226+ def test_error_model_without_optional_fields () -> None :
227+ """Tests that Error model accepts responses missing optional translation fields."""
228+ error = Error (code = "invalid_format" , message = "required key not provided" )
229+ assert error .code == "invalid_format"
230+ assert error .translation_key is None
231+ assert error .translation_placeholders is None
232+ assert error .translation_domain is None
You can’t perform that action at this time.
0 commit comments