Skip to content

Commit

Permalink
Update GPG key deletion test
Browse files Browse the repository at this point in the history
This updates the test to work when it is executed from the development
environment where most of the Storage Service environment variables
are not set and OS tools are not installed.
  • Loading branch information
replaceafill committed Oct 22, 2024
1 parent 8d7b92a commit 3cb2091
Showing 1 changed file with 24 additions and 1 deletion.
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

0 comments on commit 3cb2091

Please sign in to comment.