Fix 'GPG_1_3_1 referenced before assignment'

- Fix gpg.import_key() exception:
    "local variable 'GPG_1_3_1' referenced before assignment"
- Update the unit tests to test both the gpg.GPG_1_3_1=True and
gpg.GPG_1_3_1=False cases.
This commit is contained in:
John Schwinghammer 2015-11-19 09:27:46 -06:00
parent 14b5d0ed0f
commit 813f6e6808
2 changed files with 4 additions and 5 deletions

View file

@ -651,11 +651,6 @@ def import_key(user=None,
imported_data = gpg.import_keys(text)
# include another check for Salt unit tests
gnupg_version = distutils.version.LooseVersion(gnupg.__version__)
if gnupg_version >= '1.3.1':
GPG_1_3_1 = True
if GPG_1_3_1:
counts = imported_data.counts
if counts.get('imported') or counts.get('imported_rsa'):

View file

@ -336,6 +336,10 @@ class GpgTestCase(TestCase):
self.assertRaises(SaltInvocationError, gpg.import_key,
filename='/path/to/public-key-file')
gpg.GPG_1_3_1 = True
self.assertDictEqual(gpg.import_key(text='-BEGIN PGP PUBLIC KEY BLOCK-'), ret)
gpg.GPG_1_3_1 = False
self.assertDictEqual(gpg.import_key(text='-BEGIN PGP PUBLIC KEY BLOCK-'), ret)
# 'export_key' function tests: 1