Exemple #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)
    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)
Exemple #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)
Exemple #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()
Exemple #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()
Exemple #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()
    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()
    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()
    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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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)
Exemple #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)