예제 #1
0
 def test_dispatch_POST(self):
     with mock_urlopen(success_response(100)):
         d = http.HttpDispatch('http://example.com/mul', 'POST', {
             'x': 10,
             'y': 10
         })
         self.assertEqual(d.dispatch(), 100)
예제 #2
0
    def test_dispatch_POST(self):
        logger = logging.getLogger('celery.unittest')

        with mock_urlopen(success_response(100)):
            d = http.HttpDispatch('http://example.com/mul', 'POST', {
                                    'x': 10, 'y': 10}, logger)
            self.assertEqual(d.dispatch(), 100)
예제 #3
0
    def test_dispatch_POST(self):
        logger = logging.getLogger("celery.unittest")

        with mock_urlopen(success_response(100)):
            d = http.HttpDispatch("http://example.com/mul", "POST", {
                                    "x": 10, "y": 10}, logger)
            self.assertEqual(d.dispatch(), 100)
예제 #4
0
 def test_dispatch_unknown_status(self):
     with mock_urlopen(unknown_response()):
         d = http.HttpDispatch('http://example.com/mul', 'GET', {
             'x': 10,
             'y': 10
         })
         with self.assertRaises(http.UnknownStatusError):
             d.dispatch()
예제 #5
0
 def test_dispatch_non_json(self):
     with mock_urlopen(_response("{'#{:'''")):
         d = http.HttpDispatch('http://example.com/mul', 'GET', {
             'x': 10,
             'y': 10
         })
         with self.assertRaises(http.InvalidResponseError):
             d.dispatch()
예제 #6
0
 def test_dispatch_failure(self):
     with mock_urlopen(fail_response('Invalid moon alignment')):
         d = http.HttpDispatch('http://example.com/mul', 'GET', {
             'x': 10,
             'y': 10
         })
         with self.assertRaises(http.RemoteExecuteError):
             d.dispatch()
예제 #7
0
    def test_dispatch_unknown_status(self):
        logger = logging.getLogger('celery.unittest')

        with mock_urlopen(unknown_response()):
            d = http.HttpDispatch('http://example.com/mul', 'GET', {
                                    'x': 10, 'y': 10}, logger)
            with self.assertRaises(http.UnknownStatusError):
                d.dispatch()
예제 #8
0
    def test_dispatch_non_json(self):
        logger = logging.getLogger('celery.unittest')

        with mock_urlopen(_response("{'#{:'''")):
            d = http.HttpDispatch('http://example.com/mul', 'GET', {
                                    'x': 10, 'y': 10}, logger)
            with self.assertRaises(http.InvalidResponseError):
                d.dispatch()
예제 #9
0
    def test_dispatch_failure(self):
        logger = logging.getLogger('celery.unittest')

        with mock_urlopen(fail_response('Invalid moon alignment')):
            d = http.HttpDispatch('http://example.com/mul', 'GET', {
                                    'x': 10, 'y': 10}, logger)
            with self.assertRaises(http.RemoteExecuteError):
                d.dispatch()
예제 #10
0
    def test_dispatch_unknown_status(self):
        logger = logging.getLogger("celery.unittest")

        with mock_urlopen(unknown_response()):
            d = http.HttpDispatch("http://example.com/mul", "GET", {
                                    "x": 10, "y": 10}, logger)
            with self.assertRaises(http.UnknownStatusError):
                d.dispatch()
예제 #11
0
    def test_dispatch_non_json(self):
        logger = logging.getLogger("celery.unittest")

        with mock_urlopen(_response("{'#{:'''")):
            d = http.HttpDispatch("http://example.com/mul", "GET", {
                                    "x": 10, "y": 10}, logger)
            with self.assertRaises(http.InvalidResponseError):
                d.dispatch()
예제 #12
0
    def test_dispatch_failure(self):
        logger = logging.getLogger("celery.unittest")

        with mock_urlopen(fail_response("Invalid moon alignment")):
            d = http.HttpDispatch("http://example.com/mul", "GET", {
                                    "x": 10, "y": 10}, logger)
            with self.assertRaises(http.RemoteExecuteError):
                d.dispatch()
예제 #13
0
 def with_mock_urlopen(_val):
     d = http.HttpDispatch("http://example.com/mul", "POST", {
         "x": 10,
         "y": 10
     }, logger)
     self.assertEqual(d.dispatch(), 100)
예제 #14
0
 def with_mock_urlopen(_val):
     d = http.HttpDispatch("http://example.com/mul", "GET", {
         "x": 10,
         "y": 10
     }, logger)
     self.assertRaises(http.UnknownStatusError, d.dispatch)