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)
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)
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()
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()
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()
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()
def with_mock_urlopen(_val): d = http.HttpDispatch("http://example.com/mul", "POST", { "x": 10, "y": 10 }, logger) self.assertEqual(d.dispatch(), 100)
def with_mock_urlopen(_val): d = http.HttpDispatch("http://example.com/mul", "GET", { "x": 10, "y": 10 }, logger) self.assertRaises(http.UnknownStatusError, d.dispatch)