コード例 #1
0
    def test_server_publish_error_thrown(self, fake_post, fake_notifiers):
        raise_http_exception = Mock(side_effect=PublishHTTPPushServerError.httpPushError(Exception('server 5xx')))

        fake_post.return_value = Mock(status_code=503, text='server 5xx', raise_for_status=raise_http_exception)

        # needed for bad exception handling classes
        fake_notifiers.return_value = []

        service = HTTPPushService()

        with self.assertRaises(PublishHTTPPushServerError):
            service._push_item(self.destination, json.dumps(self.item))
コード例 #2
0
    def test_server_publish_error_thrown(self, fake_post, fake_notifiers):
        raise_http_exception = Mock(side_effect=PublishHTTPPushServerError.httpPushError(Exception('server 5xx')))

        fake_post.return_value = Mock(status_code=503, text='server 5xx', raise_for_status=raise_http_exception)

        # needed for bad exception handling classes
        fake_notifiers.return_value = []

        service = HTTPPushService()

        with self.assertRaises(PublishHTTPPushServerError):
            service._push_item(self.destination, json.dumps(self.item))
コード例 #3
0
    def test_client_publish_error_thrown(self, fake_post, fake_notifiers):
        with self.app.app_context():
            raise_http_exception = Mock(side_effect=PublishHTTPPushClientError.httpPushError(Exception("client 4xx")))

        fake_post.return_value = Mock(status_code=401, text="client 4xx", raise_for_status=raise_http_exception)

        # needed for bad exception handling classes
        fake_notifiers.return_value = []

        service = HTTPPushService()

        with self.assertRaises(PublishHTTPPushClientError):
            with self.app.app_context():
                service._push_item(self.destination, json.dumps(self.item))