Ejemplo n.º 1
0
def test_signed_status_change(config, get_csrf_request_with_db,
                              full_estimation, user):
    config.testing_securitypolicy(userid="test",
                                  groupids=('admin', ),
                                  permissive=True)
    from autonomie.views.estimations.rest_api import (
        EstimationSignedStatusRestView, )

    request = get_csrf_request_with_db(post={'submit': 'aborted'})
    request.context = full_estimation
    request.user = user
    request.is_xhr = True

    view = EstimationSignedStatusRestView(request)
    result = view.__call__()
    assert result['datas'] == {'signed_status': 'aborted'}
Ejemplo n.º 2
0
def test_signed_status_change_forbidden(config, get_csrf_request_with_db,
                                        full_estimation, user):
    config.testing_securitypolicy(userid="test",
                                  groupids=('admin', ),
                                  permissive=False)
    from autonomie.utils.rest import RestError
    from autonomie.views.estimations.rest_api import (
        EstimationSignedStatusRestView, )

    request = get_csrf_request_with_db(post={'submit': 'signed'})
    request.context = full_estimation
    request.user = user
    request.is_xhr = True

    view = EstimationSignedStatusRestView(request)
    with pytest.raises(RestError) as forbidden_exc:
        view.__call__()
    assert forbidden_exc.value.code == 403
Ejemplo n.º 3
0
def test_signed_status_change(
    config, get_csrf_request_with_db, full_estimation, user
):
    config.testing_securitypolicy(
        userid="test",
        groupids=('admin',),
        permissive=True
    )
    from autonomie.views.estimations.rest_api import (
        EstimationSignedStatusRestView,
    )

    request = get_csrf_request_with_db(
        post={'submit': 'aborted'}
    )
    request.context = full_estimation
    request.user = user
    request.is_xhr = True

    view = EstimationSignedStatusRestView(request)
    result = view.__call__()
    assert result['datas'] == {'signed_status': 'aborted'}
Ejemplo n.º 4
0
def test_signed_status_change_wrong(
    config, get_csrf_request_with_db, full_estimation, user
):
    config.testing_securitypolicy(
        userid="test",
        groupids=('admin',),
        permissive=True
    )
    from autonomie.utils.rest import RestError
    from autonomie.views.estimations.rest_api import (
        EstimationSignedStatusRestView,
    )

    request = get_csrf_request_with_db(
        post={'submit': 'wrong'}
    )
    request.context = full_estimation
    request.user = user
    request.is_xhr = True

    view = EstimationSignedStatusRestView(request)
    with pytest.raises(RestError) as invalid_exc:
        view.__call__()
    assert invalid_exc.value.code == 400