def test_creating_exception_from_call_error(): call_error = CallError(unique_id="1337", error_code="ProtocolError", error_description="Something went wrong", error_details="Some details about the error") assert call_error.to_exception() == ProtocolError( description="Something went wrong", details="Some details about the error")
def test_creating_exception_from_call_error_with_unknown_error_code(): call_error = CallError( unique_id="1337", error_code="418", error_description="I'm a teapot", ) with pytest.raises(UnknownCallErrorCodeError): call_error.to_exception()
async def test_suppress_call_error(base_central_system): """ Test that getting a CallError will suppress Exception by default """ call_error = CallError( unique_id='1337', error_code="GenericError", error_description='test_raise_call_error', ) await base_central_system.route_message(call_error.to_json()) payload = call.ClearCachePayload() await base_central_system.call(payload)
async def test_raise_call_error(base_central_system): """ Test that getting a CallError will raise an Exception if suppress argument is not True. """ call_error = CallError( unique_id='1337', error_code="GenericError", error_description='test_raise_call_error', ) await base_central_system.route_message(call_error.to_json()) payload = call.ClearCachePayload() with pytest.raises(GenericError): await base_central_system.call(payload, suppress=False)
def test_call_error_representation(): call = CallError(unique_id=1, error_code="GenericError", error_description="Some message", error_details={}) assert str(call) == \ "<CallError - unique_id=1, error_code=GenericError, " \ "error_description=Some message, error_details={}>"