fix truth evaluation of import results

for some reason, the count was accessed as if it was a Storage
instance, and it's not, it behaves as a dictionnary

includes test case that will fail with the original code
fix/44-verbose-arg
Antoine Beaupré 2014-08-29 11:02:11 -07:00
parent 961bf8da1b
commit 293fa6b2e0
No known key found for this signature in database
GPG Key ID: 792152527B75921E
2 changed files with 2 additions and 2 deletions

View File

@ -1048,7 +1048,7 @@ class ImportResult(object):
:rtype: bool
:returns: True if we have immport some keys, False otherwise.
"""
if self.counts.not_imported > 0: return False
if self.counts['not_imported'] > 0: return False
if len(self.fingerprints) == 0: return False
return True
__bool__ = __nonzero__

View File

@ -564,7 +564,7 @@ class GPGTestCase(unittest.TestCase):
def test_import_only(self):
"""Test that key import works."""
self.test_list_keys_initial_public()
self.gpg.import_keys(KEYS_TO_IMPORT)
self.assertTrue(self.gpg.import_keys(KEYS_TO_IMPORT))
public_keys = self.gpg.list_keys()
self.assertTrue(is_list_with_len(public_keys, 2),
"2-element list expected")