Ejemplo n.º 1
0
    def test_invalid_request_object_accepts_errors(self):
        request = req.InvalidRequestObject()
        request.add_error(parameter='aparam', message='wrong value')
        request.add_error(parameter='anotherparam', message='wrong type')

        self.assertTrue(request.has_errors())
        self.assertEqual(len(request.errors), 2)
Ejemplo n.º 2
0
    def test_use_case_can_process_invalid_requests_and_returns_response_failure(self):
        invalid_request_object = req.InvalidRequestObject()
        invalid_request_object.add_error('someparam', 'somemessage')

        use_case = uc.UseCase()
        response = use_case.execute(invalid_request_object)

        assert not response
        assert response.type == res.ResponseFailure.PARAMETERS_ERROR
        assert response.message == 'someparam: somemessage'
Ejemplo n.º 3
0
    def test_response_failure_from_invalid_request_object_with_errors(self):
        request_object = req.InvalidRequestObject()
        request_object.add_error('path', 'Is mandatory')
        request_object.add_error('path', "can't be blank")

        response = res.ResponseFailure.build_from_invalid_request_object(
            request_object)

        self.assertEqual(bool(response), False)
        self.assertEqual(response.type, res.ResponseFailure.PARAMETERS_ERROR)
        self.assertEqual(response.message,
                         "path: Is mandatory\npath: can't be blank")
Ejemplo n.º 4
0
 def test_invalid_request_object_is_false(self):
     request = req.InvalidRequestObject()
     self.assertFalse(bool(request))
Ejemplo n.º 5
0
    def test_response_failure_from_invalid_request_object(self):
        response = res.ResponseFailure.build_from_invalid_request_object(
            req.InvalidRequestObject())

        self.assertEqual(bool(response), False)