|
33 | 33 | from mock import Mock |
34 | 34 |
|
35 | 35 | # module under test |
36 | | -from azure.core.exceptions import HttpResponseError, ODataV4Error, ODataV4Format |
| 36 | +from azure.core.exceptions import HttpResponseError, ODataV4Error, ODataV4Format, SerializationError, DeserializationError |
37 | 37 | from azure.core.pipeline.transport import RequestsTransportResponse |
38 | 38 | from azure.core.pipeline.transport._base import _HttpResponseBase as PipelineTransportHttpResponseBase |
39 | 39 | from azure.core.rest._http_response_impl import _HttpResponseBaseImpl as RestHttpResponseBase |
@@ -320,3 +320,25 @@ def test_datav4_error(self, client, http_request): |
320 | 320 | with pytest.raises(HttpResponseError) as ex: |
321 | 321 | response.raise_for_status() |
322 | 322 | assert "Content: {\"" not in str(ex.value) |
| 323 | + |
| 324 | +def test_serialization_error(): |
| 325 | + message = "Oopsy bad input passed for serialization" |
| 326 | + error = SerializationError(message) |
| 327 | + with pytest.raises(SerializationError) as ex: |
| 328 | + raise error |
| 329 | + assert str(ex.value) == message |
| 330 | + |
| 331 | + with pytest.raises(ValueError) as ex: |
| 332 | + raise error |
| 333 | + assert str(ex.value) == message |
| 334 | + |
| 335 | +def test_deserialization_error(): |
| 336 | + message = "Oopsy bad input passed for serialization" |
| 337 | + error = DeserializationError(message) |
| 338 | + with pytest.raises(DeserializationError) as ex: |
| 339 | + raise error |
| 340 | + assert str(ex.value) == message |
| 341 | + |
| 342 | + with pytest.raises(ValueError) as ex: |
| 343 | + raise error |
| 344 | + assert str(ex.value) == message |
0 commit comments