Skip to content

Commit

Permalink
Adjust delete project functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
luxusko committed Sep 26, 2023
1 parent f88d913 commit d0d0f81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions server/mergin/sync/db_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ def register_events():

def remove_events():
event.remove(User, "before_delete", remove_user_references)
event.remove(Project, "before_delete", remove_project_storage)
event.remove(db.session, "before_commit", check)
6 changes: 3 additions & 3 deletions server/mergin/sync/public_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tags:
- name: project
description: Mergin project
paths:
/project/{id}:
/projects/{id}:
delete:
tags:
- project
Expand All @@ -27,8 +27,8 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
x-openapi-router-controller: mergin.sync.public_api_v2_controller
/project/{id}/scheduleDelete:
delete:
/projects/{id}/scheduleDelete:
post:
tags:
- project
summary: Schedule project to delete
Expand Down
12 changes: 6 additions & 6 deletions server/mergin/tests/test_public_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ def test_schedule_delete_project(client):
project = Project.query.filter_by(
workspace_id=test_workspace_id, name=test_project
).first()
response = client.delete(f"v2/project/{project.id}/scheduleDelete")
response = client.post(f"v2/projects/{project.id}/scheduleDelete")
assert response.status_code == 204
updated = Project.query.get(project.id)
assert updated.removed_at and updated.removed_by
response = client.delete(f"v2/project/{project.id}/scheduleDelete")
response = client.post(f"v2/projects/{project.id}/scheduleDelete")
assert response.status_code == 404


def test_delete_project_now(client):
project = Project.query.filter_by(
workspace_id=test_workspace_id, name=test_project
).first()
response = client.delete(f"v2/project/{project.id}")
response = client.delete(f"v2/projects/{project.id}")
assert response.status_code == 204
assert not Project.query.get(project.id)
response = client.delete(f"v2/project/{project.id}")
response = client.delete(f"v2/projects/{project.id}")
assert response.status_code == 404


def test_delete_after_schedule(client):
project = Project.query.filter_by(
workspace_id=test_workspace_id, name=test_project
).first()
response = client.delete(f"v2/project/{project.id}/scheduleDelete")
response = client.post(f"v2/projects/{project.id}/scheduleDelete")
assert response.status_code == 204
response = client.delete(f"v2/project/{project.id}")
response = client.delete(f"v2/projects/{project.id}")
assert response.status_code == 204

0 comments on commit d0d0f81

Please sign in to comment.