def bad_request_raises_no_exception_test(self, requests_get_patch): response = MockResponse('foo', 400, '') requests_get_patch.return_value = response c = Connection(api_key="testkey") c.get("foo")
def ok_post_raises_no_exception_test(self, requests_post_patch): response = MockResponse('foo', 200, '') requests_post_patch.return_value = response c = Connection(api_key="testkey") c.post("foo", "bar")
def ok_post_raises_no_exception_test( self, requests_post_patch): response = MockResponse('foo', 200, '') requests_post_patch.return_value = response c = Connection(api_key="testkey") c.post("foo", "bar")
def bad_request_raises_no_exception_test( self, requests_get_patch): response = MockResponse('foo', 400, '') requests_get_patch.return_value = response c = Connection(api_key="testkey") c.get("foo")
def not_found_raises_ExecutionFailureException_test( self, requests_get_patch): response = Response() response.status_code = 404 requests_get_patch.return_value = response c = Connection(api_key="testkey") with self.assertRaises(ResourceNotFoundException): c.get("foo")
def server_error_raises_ExecutionFailureException_test( self, requests_get_patch): response = Response() response.status_code = 500 requests_get_patch.return_value = response c = Connection(api_key="testkey") with self.assertRaises(ExecutionFailureException): c.get("foo")
def bad_authentication_raises_AuthorizationException_test( self, requests_get_patch): response = Response() response.status_code = 401 requests_get_patch.return_value = response c = Connection(api_key="testkey") with self.assertRaises(AuthorizationException): c.get("foo") response = Response() response.status_code = 403 requests_get_patch.return_value = response c = Connection(api_key="testkey") with self.assertRaises(AuthorizationException): c.get("foo")
def passing_None_for_api_key_raises_exception_test(self): with self.assertRaises(ValueError): Connection(api_key=None)