Example #1
0
    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")
Example #2
0
    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")
Example #3
0
    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")
Example #4
0
    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")
Example #5
0
    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")
Example #6
0
    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")
Example #7
0
    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")
Example #8
0
    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")
Example #9
0
    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")
Example #10
0
    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")
Example #11
0
 def passing_None_for_api_key_raises_exception_test(self):
     with self.assertRaises(ValueError):
         Connection(api_key=None)