예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #11
0
 def passing_None_for_api_key_raises_exception_test(self):
     with self.assertRaises(ValueError):
         Connection(api_key=None)