diff --git a/Makefile b/Makefile index db9f90029977..971f9da4f6c3 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ initdb: docker-compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'" xz -d -f -k dev/$(DB).sql.xz --stdout | docker-compose run --rm web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f - docker-compose run --rm web python -m warehouse db upgrade head - $(MAKE) reindex + # $(MAKE) reindex reindex: docker-compose run --rm web python -m warehouse search reindex diff --git a/tests/unit/utils/test_project.py b/tests/unit/utils/test_project.py index 321cfa87c2e5..f5a5d2342047 100644 --- a/tests/unit/utils/test_project.py +++ b/tests/unit/utils/test_project.py @@ -27,8 +27,8 @@ from warehouse.utils.project import ( confirm_project, destroy_docs, + destroy_project, remove_documentation, - remove_project, ) from ...common.db.accounts import UserFactory @@ -92,8 +92,7 @@ def test_confirm_incorrect_input(): ] -@pytest.mark.parametrize("flash", [True, False]) -def test_remove_project(db_request, flash): +def test_destroy_project(db_request): user = UserFactory.create() project = ProjectFactory.create(name="foo") release = ReleaseFactory.create(project=project) @@ -105,15 +104,11 @@ def test_remove_project(db_request, flash): db_request.remote_addr = "192.168.1.1" db_request.session = stub(flash=call_recorder(lambda *a, **kw: stub())) - remove_project(project, db_request, flash=flash) - - if flash: - assert db_request.session.flash.calls == [ - call("Deleted the project 'foo'", queue="success") - ] - else: - assert db_request.session.flash.calls == [] + destroy_project(project, db_request) + assert db_request.session.flash.calls == [ + call("Deleted the project 'foo'", queue="success") + ] assert not (db_request.db.query(Role).filter(Role.project == project).count()) assert not ( db_request.db.query(File) @@ -144,8 +139,7 @@ def test_remove_project(db_request, flash): assert journal_entry.submitted_from == db_request.remote_addr -@pytest.mark.parametrize("flash", [True, False]) -def test_destroy_docs(db_request, flash): +def test_destroy_docs(db_request): user = UserFactory.create() project = ProjectFactory.create(name="foo", has_docs=True) RoleFactory.create(user=user, project=project) @@ -156,7 +150,7 @@ def test_destroy_docs(db_request, flash): remove_documentation_recorder = stub(delay=call_recorder(lambda *a, **kw: None)) db_request.task = call_recorder(lambda *a, **kw: remove_documentation_recorder) - destroy_docs(project, db_request, flash=flash) + destroy_docs(project, db_request) journal_entry = ( db_request.db.query(JournalEntry) @@ -176,13 +170,11 @@ def test_destroy_docs(db_request, flash): ) assert remove_documentation_recorder.delay.calls == [call("foo")] + assert db_request.session.flash.calls == [ + call("Deleted docs for project 'foo'", queue="success") + ] + - if flash: - assert db_request.session.flash.calls == [ - call("Deleted docs for project 'foo'", queue="success") - ] - else: - assert db_request.session.flash.calls == [] def test_remove_documentation(db_request): diff --git a/warehouse/admin/routes.py b/warehouse/admin/routes.py index ffda496c8467..a7832a54b4c4 100644 --- a/warehouse/admin/routes.py +++ b/warehouse/admin/routes.py @@ -102,6 +102,13 @@ def includeme(config): traverse="/{project_name}", domain=warehouse, ) + config.add_route( + "admin.project.restore", + "/admin/projects/{project_name}/restore/", + factory="warehouse.packaging.models:ProjectFactory", + traverse="/{project_name}", + domain=warehouse, + ) # Journal related Admin pages config.add_route("admin.journals.list", "/admin/journals/", domain=warehouse) diff --git a/warehouse/admin/templates/admin/projects/delete.html b/warehouse/admin/templates/admin/projects/delete.html index f650f2fc32d9..59cc3af5f49f 100644 --- a/warehouse/admin/templates/admin/projects/delete.html +++ b/warehouse/admin/templates/admin/projects/delete.html @@ -19,7 +19,7 @@
- Deleting will irreversibly delete this project along with + This will irreversibly remove this project from the database along with {{ project.releases|length() }} releases.