Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GPG key deletion test #751

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion tests/administration/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pytest
from administration.views import get_git_commit
from django.urls import reverse
from locations.models import Location
from locations.models import Space


@pytest.mark.parametrize(
Expand All @@ -23,8 +25,29 @@ def test_get_git_commit(check_output, expected_result, mocker):
assert get_git_commit() == expected_result


@pytest.fixture
def space(tmp_path):
space_dir = tmp_path / "space"
space_dir.mkdir()

return Space.objects.create(path=str(space_dir))


@pytest.fixture
def ss_internal_location(space):
return Location.objects.create(
space=space,
relative_path="storage_service",
purpose=Location.STORAGE_SERVICE_INTERNAL,
)


@pytest.mark.django_db
@mock.patch("gnupg.GPG.export_keys", return_value="")
@mock.patch("gnupg.GPG.list_keys")
def test_deleting_key_from_detail_view_redirects_to_key_list(list_keys, admin_client):
def test_deleting_key_from_detail_view_redirects_to_key_list(
list_keys, export_keys, admin_client, ss_internal_location
):
key_fingerprint = "3173C7395C551A6647656A5065C0718327F7B2C7"
list_keys.return_value = mock.Mock(
key_map={
Expand Down