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

    assert request.has_errors() is True
    assert len(request.errors) == 2
Esempio n. 2
0
def test_use_case_can_process_invalid_requests_and_returns_response_failure():
    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'
Esempio n. 3
0
def test_response_failure_from_invalid_request_object_with_errors():
    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)

    assert bool(response) is False
    assert response.type == res.ResponseFailure.PARAMETERS_ERROR
    assert response.message == "path: Is mandatory\npath: can't be blank"
Esempio n. 4
0
def test_invalid_request_object_is_false():
    request = req.InvalidRequestObject()

    assert bool(request) is False
Esempio n. 5
0
def test_response_failure_from_invalid_request_object():
    response = res.ResponseFailure.build_from_invalid_request_object(
        req.InvalidRequestObject())

    assert bool(response) is False