From 8a2688c30bd8cd1e0022bbde3315be177181fb73 Mon Sep 17 00:00:00 2001 From: "Douglas Cerna (Soy Douglas)" Date: Mon, 21 Oct 2024 15:54:37 +0000 Subject: [PATCH] Update GPG key deletion test 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. --- tests/administration/test_views.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/administration/test_views.py b/tests/administration/test_views.py index bb0e1a6cf..7906361ae 100644 --- a/tests/administration/test_views.py +++ b/tests/administration/test_views.py @@ -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( @@ -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={