aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/model/tests/test_list.py
diff options
context:
space:
mode:
authorJ08nY2017-08-21 21:12:31 +0200
committerJ08nY2017-08-21 21:12:31 +0200
commitc21e5e0e2841e1d516ffe75717b10c09ef3489ba (patch)
tree21773c460afda1b064013be6a12046deaf17fc62 /src/mailman_pgp/model/tests/test_list.py
parent006e63dd02ae03e4e0d29405ba7b8c530a20fc9c (diff)
downloadmailman-pgp-c21e5e0e2841e1d516ffe75717b10c09ef3489ba.tar.gz
mailman-pgp-c21e5e0e2841e1d516ffe75717b10c09ef3489ba.tar.zst
mailman-pgp-c21e5e0e2841e1d516ffe75717b10c09ef3489ba.zip
Diffstat (limited to 'src/mailman_pgp/model/tests/test_list.py')
-rw-r--r--src/mailman_pgp/model/tests/test_list.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mailman_pgp/model/tests/test_list.py b/src/mailman_pgp/model/tests/test_list.py
index 9bb0a4e..eb43355 100644
--- a/src/mailman_pgp/model/tests/test_list.py
+++ b/src/mailman_pgp/model/tests/test_list.py
@@ -16,6 +16,8 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
""""""
+import shutil
+import unittest
from os.path import exists
from unittest import TestCase
@@ -23,9 +25,9 @@ from mailman.app.lifecycle import create_list
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
-from mailman_pgp.config import config
from mailman_pgp.database import mm_transaction
from mailman_pgp.model.list import PGPMailingList
+from mailman_pgp.testing.config import patch_config
from mailman_pgp.testing.layers import PGPConfigLayer
from mailman_pgp.testing.pgp import load_key
@@ -50,9 +52,11 @@ class TestPGPMailingList(TestCase):
getUtility(IListManager).delete(self.mlist)
self.assertFalse(exists(key_path))
+ @patch_config('keypairs', 'shred_command', 'shred')
+ @unittest.skipIf(shutil.which('shred') is None, 'No shred command.')
def test_shred_key_command(self):
- self.addCleanup(config.set, 'keypairs', 'shred_command', '')
- config.set('keypairs', 'shred_command', 'shred')
+ # This really just hopes that the test env has some coreutils, that
+ # provide `shred` command with this behaviour.
key_path = PGPMailingList.for_list(self.mlist).key_path
with open(key_path, 'rb') as f:
before = f.read()
@@ -61,9 +65,8 @@ class TestPGPMailingList(TestCase):
after = f.read()
self.assertNotEqual(before, after)
+ @patch_config('keypairs', 'shred', 'no')
def test_delete_key(self):
- self.addCleanup(config.set, 'keypairs', 'shred', 'yes')
- config.set('keypairs', 'shred', 'no')
key_path = PGPMailingList.for_list(self.mlist).key_path
getUtility(IListManager).delete(self.mlist)
self.assertFalse(exists(key_path))