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 io import BytesIO
23
from StringIO import StringIO as BytesIO
24
from textwrap import dedent
27
from gpgme.tests.util import GpgHomeTestCase
29
class ProgressTestCase(GpgHomeTestCase):
31
import_keys = ['key1.pub', 'key1.sec']
33
def progress_cb(self, what, type_, current, total):
34
self.progress_cb_called = True
36
def test_sign_with_progress_cb(self):
38
key = ctx.get_key('E79A842DA34A1CA383F64A1546BB55F0885C65A4')
40
ctx.progress_cb = self.progress_cb
41
plaintext = BytesIO('Hello World\n')
44
self.progress_cb_called = False
45
new_sigs = ctx.sign(plaintext, signature, gpgme.SIG_MODE_CLEAR)
47
# ensure that progress_cb has been run
48
self.assertEqual(self.progress_cb_called, True)
50
self.assertEqual(new_sigs[0].type, gpgme.SIG_MODE_CLEAR)
51
self.assertEqual(new_sigs[0].fpr,
52
'E79A842DA34A1CA383F64A1546BB55F0885C65A4')
55
loader = unittest.TestLoader()
56
return loader.loadTestsFromName(__name__)