1
# pygpgme - a Python wrapper for the gpgme library
2
# Copyright (C) 2006 James Henstridge
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Lesser General Public
6
# License as published by the Free Software Foundation; either
7
# version 2.1 of the License, or (at your option) any later version.
9
# This library is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public
15
# License along with this library; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
from gpgme.tests.util import GpgHomeTestCase
23
class DeleteTestCase(GpgHomeTestCase):
25
import_keys = ['key1.pub', 'key1.sec', 'key2.pub']
27
def test_delete_public_key(self):
30
key = ctx.get_key('93C2240D6B8AA10AB28F701D2CF46B7FC97E6B0F')
33
# check that it is deleted
34
self.assertRaises(gpgme.GpgmeError, ctx.get_key,
35
'93C2240D6B8AA10AB28F701D2CF46B7FC97E6B0F')
37
def test_delete_public_key_with_secret_key(self):
40
key = ctx.get_key('E79A842DA34A1CA383F64A1546BB55F0885C65A4')
41
self.assertRaises(gpgme.GpgmeError, ctx.delete, key)
43
def test_delete_secret_key(self):
46
key = ctx.get_key('E79A842DA34A1CA383F64A1546BB55F0885C65A4')
49
def test_delete_non_existant(self):
52
key = ctx.get_key('93C2240D6B8AA10AB28F701D2CF46B7FC97E6B0F')
58
except gpgme.GpgmeError, exc:
59
self.assertEqual(exc[0], gpgme.ERR_SOURCE_GPGME)
60
self.assertEqual(exc[1], gpgme.ERR_NO_PUBKEY)
62
self.fail('gpgme.GpgmeError was not raised')
66
loader = unittest.TestLoader()
67
return loader.loadTestsFromName(__name__)