Esempio n. 1
0
def destroy_project_docs(project, request):
    confirm_project(project, request, fail_route="manage.project.documentation")
    destroy_docs(project, request)

    return HTTPSeeOther(
        request.route_path(
            "manage.project.documentation", project_name=project.normalized_name
        )
    )
Esempio n. 2
0
def destroy_project_docs(project, request):
    confirm_project(project,
                    request,
                    fail_route="manage.project.documentation")
    destroy_docs(project, request)

    return HTTPSeeOther(
        request.route_path("manage.project.documentation",
                           project_name=project.normalized_name))
Esempio n. 3
0
def test_confirm():
    project = stub(normalized_name="foobar")
    request = stub(
        POST={"confirm_project_name": "foobar"},
        route_path=call_recorder(lambda *a, **kw: stub()),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    confirm_project(project, request, fail_route="fail_route")

    assert request.route_path.calls == []
    assert request.session.flash.calls == []
Esempio n. 4
0
def test_confirm():
    project = stub(normalized_name='foobar')
    request = stub(
        POST={'confirm_project_name': 'foobar'},
        route_path=call_recorder(lambda *a, **kw: stub()),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    confirm_project(project, request, fail_route='fail_route')

    assert request.route_path.calls == []
    assert request.session.flash.calls == []
Esempio n. 5
0
def test_confirm_no_input():
    project = stub(normalized_name="foobar")
    request = stub(
        POST={"confirm_project_name": ""},
        route_path=call_recorder(lambda *a, **kw: "/the-redirect"),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route="fail_route")
        assert err.value == "/the-redirect"

    assert request.route_path.calls == [call("fail_route", project_name="foobar")]
    assert request.session.flash.calls == [call("Confirm the request", queue="error")]
Esempio n. 6
0
def test_confirm_no_input():
    project = stub(normalized_name="foobar")
    request = stub(
        POST={"confirm_project_name": ""},
        route_path=call_recorder(lambda *a, **kw: "/the-redirect"),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route="fail_route")
        assert err.value == "/the-redirect"

    assert request.route_path.calls == [call("fail_route", project_name="foobar")]
    assert request.session.flash.calls == [call("Confirm the request", queue="error")]
Esempio n. 7
0
def delete_project(project, request):
    if request.flags.enabled(AdminFlagValue.DISALLOW_DELETION):
        request.session.flash(
            ("Project deletion temporarily disabled. "
             "See https://pypi.org/help#admin-intervention for details."),
            queue="error",
        )
        return HTTPSeeOther(
            request.route_path("manage.project.settings",
                               project_name=project.name))

    confirm_project(project, request, fail_route="manage.project.settings")
    remove_project(project, request)

    return HTTPSeeOther(request.route_path("manage.projects"))
Esempio n. 8
0
def test_confirm_no_input():
    project = stub(normalized_name='foobar')
    request = stub(
        POST={'confirm_project_name': ''},
        route_path=call_recorder(lambda *a, **kw: '/the-redirect'),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route='fail_route')
        assert err.value == '/the-redirect'

    assert request.route_path.calls == [
        call('fail_route', project_name='foobar')
    ]
    assert request.session.flash.calls == [
        call('Must confirm the request.', queue='error')
    ]
Esempio n. 9
0
def test_confirm_no_input():
    project = stub(normalized_name='foobar')
    request = stub(
        POST={'confirm_project_name': ''},
        route_path=call_recorder(lambda *a, **kw: '/the-redirect'),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route='fail_route')
        assert err.value == '/the-redirect'

    assert request.route_path.calls == [
        call('fail_route', project_name='foobar')
    ]
    assert request.session.flash.calls == [
        call('Must confirm the request', queue='error')
    ]
Esempio n. 10
0
def test_confirm_incorrect_input():
    project = stub(normalized_name='foobar')
    request = stub(
        POST={'confirm_project_name': 'bizbaz'},
        route_path=call_recorder(lambda *a, **kw: '/the-redirect'),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route='fail_route')
        assert err.value == '/the-redirect'

    assert request.route_path.calls == [
        call('fail_route', project_name='foobar')
    ]
    assert request.session.flash.calls == [
        call("Could not delete project - 'bizbaz' is not the same as 'foobar'",
             queue='error')
    ]
Esempio n. 11
0
def test_confirm_incorrect_input():
    project = stub(normalized_name='foobar')
    request = stub(
        POST={'confirm_project_name': 'bizbaz'},
        route_path=call_recorder(lambda *a, **kw: '/the-redirect'),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route='fail_route')
        assert err.value == '/the-redirect'

    assert request.route_path.calls == [
        call('fail_route', project_name='foobar')
    ]
    assert request.session.flash.calls == [
        call(
            "Could not delete project - 'bizbaz' is not the same as 'foobar'",
            queue='error'
        )
    ]
Esempio n. 12
0
def test_confirm_incorrect_input():
    project = stub(normalized_name="foobar")
    request = stub(
        POST={"confirm_project_name": "bizbaz"},
        route_path=call_recorder(lambda *a, **kw: "/the-redirect"),
        session=stub(flash=call_recorder(lambda *a, **kw: stub())),
    )

    with pytest.raises(HTTPSeeOther) as err:
        confirm_project(project, request, fail_route="fail_route")
    assert err.value.location == "/the-redirect"

    assert request.route_path.calls == [
        call("fail_route", project_name="foobar")
    ]
    assert request.session.flash.calls == [
        call(
            "Could not delete project - 'bizbaz' is not the same as 'foobar'",
            queue="error",
        )
    ]
Esempio n. 13
0
def delete_project(project, request):
    confirm_project(project, request, fail_route="admin.project.detail")
    remove_project(project, request)

    return HTTPSeeOther(request.route_path("admin.project.list"))
Esempio n. 14
0
def delete_project(project, request):
    confirm_project(project, request, fail_route="manage.project.settings")
    remove_project(project, request)

    return HTTPSeeOther(request.route_path("manage.projects"))
Esempio n. 15
0
def delete_project(project, request):
    confirm_project(project, request, fail_route="manage.project.settings")
    remove_project(project, request)

    return HTTPSeeOther(request.route_path("manage.projects"))
Esempio n. 16
0
def delete_project(project, request):
    confirm_project(project, request, fail_route="admin.project.detail")
    remove_project(project, request)

    return HTTPSeeOther(request.route_path('admin.project.list'))