Пример #1
0
    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))
Пример #2
0
    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))
Пример #3
0
    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))
Пример #4
0
    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))