diff options
| author | J08nY | 2017-07-31 02:34:00 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-31 02:34:00 +0200 |
| commit | a07fe54b768359360bbcd84ea04dfe204637849d (patch) | |
| tree | 7bd8256b8173dac249dbc07c493e6f4bcddb72f4 /src/mailman_pgp/model | |
| parent | 6d87f5b0c8c7e7a3f71e0c5d5392201b4e4769ff (diff) | |
| download | mailman-pgp-a07fe54b768359360bbcd84ea04dfe204637849d.tar.gz mailman-pgp-a07fe54b768359360bbcd84ea04dfe204637849d.tar.zst mailman-pgp-a07fe54b768359360bbcd84ea04dfe204637849d.zip | |
Diffstat (limited to 'src/mailman_pgp/model')
| -rw-r--r-- | src/mailman_pgp/model/list.py | 8 | ||||
| -rw-r--r-- | src/mailman_pgp/model/tests/__init__.py | 0 | ||||
| -rw-r--r-- | src/mailman_pgp/model/tests/test_list.py | 41 |
3 files changed, 45 insertions, 4 deletions
diff --git a/src/mailman_pgp/model/list.py b/src/mailman_pgp/model/list.py index a0101a7..8448368 100644 --- a/src/mailman_pgp/model/list.py +++ b/src/mailman_pgp/model/list.py @@ -23,7 +23,7 @@ from os.path import exists, isfile, join from flufl.lock import Lock from mailman.database.types import Enum, SAUnicode from mailman.interfaces.action import Action -from mailman.interfaces.listmanager import IListManager, ListDeletedEvent +from mailman.interfaces.listmanager import (IListManager, ListDeletingEvent) from pgpy import PGPKey from public import public from sqlalchemy import Boolean, Column, Integer @@ -153,9 +153,9 @@ class PGPMailingList(Base): return PGPMailingList.query().filter_by(list_id=mlist.list_id).first() -@classhandler.handler(ListDeletedEvent) -def on_delete(mlist): - pgp_list = PGPMailingList.for_list(mlist) +@classhandler.handler(ListDeletingEvent) +def on_delete(event): + pgp_list = PGPMailingList.for_list(event.mailing_list) if pgp_list: with transaction() as session: # TODO shred the list key diff --git a/src/mailman_pgp/model/tests/__init__.py b/src/mailman_pgp/model/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/mailman_pgp/model/tests/__init__.py diff --git a/src/mailman_pgp/model/tests/test_list.py b/src/mailman_pgp/model/tests/test_list.py new file mode 100644 index 0000000..58f52f2 --- /dev/null +++ b/src/mailman_pgp/model/tests/test_list.py @@ -0,0 +1,41 @@ +# Copyright (C) 2017 Jan Jancar +# +# This file is a part of the Mailman PGP plugin. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see <http://www.gnu.org/licenses/>. + +"""""" +from unittest import TestCase + +from mailman.app.lifecycle import create_list +from mailman.interfaces.listmanager import IListManager +from zope.component import getUtility + +from mailman_pgp.database import mm_transaction +from mailman_pgp.model.list import PGPMailingList +from mailman_pgp.testing.layers import PGPConfigLayer + + +class TestPGPMailingList(TestCase): + layer = PGPConfigLayer + + def setUp(self): + with mm_transaction(): + self.mlist = create_list('test@example.com', + style_name='pgp-default') + + def test_delete(self): + getUtility(IListManager).delete(self.mlist) + pgp_list = PGPMailingList.for_list(self.mlist) + self.assertIsNone(pgp_list) |
