def test_successful_request(self): @task_webhook def add_webhook(request): x = int(request.GET["x"]) y = int(request.GET["y"]) return x + y request = MockRequest().get("/tasks/add", dict(x=10, y=10)) response = add_webhook(request) self.assertDictContainsSubset({"status": "success", "retval": 20}, deserialize(response.content))
def test_successful_request(self): @task_webhook def add_webhook(request): x = int(request.GET['x']) y = int(request.GET['y']) return x + y request = MockRequest().get('/tasks/add', dict(x=10, y=10)) response = add_webhook(request) self.assertDictContainsSubset({'status': 'success', 'retval': 20}, deserialize(response.content))
def test_failed_request(self): @task_webhook def error_webhook(request): x = int(request.GET["x"]) y = int(request.GET["y"]) raise MyError(x + y) request = MockRequest().get("/tasks/error", dict(x=10, y=10)) response = error_webhook(request) self.assertDictContainsSubset({"status": "failure", "reason": "20"}, deserialize(response.content))
def test_failed_request(self): @task_webhook def error_webhook(request): x = int(request.GET['x']) y = int(request.GET['y']) raise MyError(x + y) request = MockRequest().get('/tasks/error', dict(x=10, y=10)) response = error_webhook(request) self.assertDictContainsSubset({'status': 'failure', 'reason': '<MyError: (20,)>'}, deserialize(response.content))