def test_create_exception_with_no_request_payload_returns_exception_with_empty_request( self): response_mock = mock.Mock(spec=requests.Response) response_mock.headers = {} response_mock.text = "text" response_mock.status_code = httplib.NOT_FOUND crud_error = crud.CRUDError('/path/', 'POST', response_mock) tools.assert_equal( '404 returned.\nMethod: POST\n' 'Correlation ID: none\nURL: /path/\nResponse: text', crud_error.message)
def test_create_exception_with_request_payload_returns_exception_with_request_payload( self): response_mock = mock.Mock(spec=requests.Response) response_mock.headers = {} response_mock.text = "text" response_mock.status_code = NOT_FOUND crud_error = crud.CRUDError('/path/', 'POST', response_mock, **{'request_payload': 'some_payload'}) tools.assert_equal( '404 returned.\nMethod: POST\n' 'Correlation ID: none\nURL: /path/\nRequest payload: "some_payload"\nResponse: text', str(crud_error))
def test_create_exception_with_request_payload_containing_decimal_data_returns_exception_with_request( self): response_mock = mock.Mock(spec=requests.Response) response_mock.headers = {} response_mock.text = "text" response_mock.status_code = httplib.NOT_FOUND request_payload = {'decimal': decimal.Decimal('3.15')} crud_error = crud.CRUDError('/path/', 'POST', response_mock, **{'request_payload': request_payload}) tools.assert_equal( '404 returned.\nMethod: POST\n' 'Correlation ID: none\nURL: /path/\nRequest payload: {\n "decimal": 3.15\n}\n' 'Response: text', crud_error.message)
def test_create_exception_with_request_parameters_returns_exception_with_parameters( self): response_mock = mock.Mock(spec=requests.Response) response_mock.headers = {} response_mock.text = "text" response_mock.status_code = httplib.NOT_FOUND crud_error = crud.CRUDError('/path/', 'POST', response_mock, **{'request_parameters': { 'a': 'b' }}) tools.assert_equal( '404 returned.\nMethod: POST\n' 'Correlation ID: none\nURL: /path/\nRequest parameters: {\n "a": "b"\n}\nResponse: text', crud_error.message)