diff options
author | Michał Górny <mgorny@gentoo.org> | 2020-09-05 15:15:32 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2020-09-05 16:15:59 +0200 |
commit | 0a95b33a5918d16450b51c2f046313cfd8771a81 (patch) | |
tree | 082c6682ff24fd06ede1f87d14f9297a9f00666e /tests/test_openpgp.py | |
parent | 35f41a15dea30c2cc00c693de8d0fe40de9b9479 (diff) | |
download | gemato-0a95b33a5918d16450b51c2f046313cfd8771a81.tar.gz |
openpgp: Move listing keys to a separate method
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'tests/test_openpgp.py')
-rw-r--r-- | tests/test_openpgp.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 5ee86aa..edeb0b9 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -642,6 +642,22 @@ def test_recursive_manifest_loader_save_submanifest(tmp_path, privkey_env): assert m2.openpgp_signature is None +@pytest.mark.parametrize( + 'key_var,expected', + [('VALID_PUBLIC_KEY', {KEY_FINGERPRINT: ['gemato@example.com']}), + ('OTHER_VALID_PUBLIC_KEY', + {OTHER_KEY_FINGERPRINT: ['gemato@example.com']}), + ('VALID_KEY_SUBKEY', {KEY_FINGERPRINT: ['gemato@example.com']}), + ('VALID_KEY_NOEMAIL', {KEY_FINGERPRINT: []}), + ]) +def test_list_keys(openpgp_env_with_refresh, key_var, expected): + try: + openpgp_env_with_refresh.import_key(io.BytesIO(globals()[key_var])) + except OpenPGPNoImplementation as e: + pytest.skip(str(e)) + assert openpgp_env_with_refresh.list_keys() == expected + + @pytest.fixture(scope='module') def global_hkp_server(): """A fixture that starts a single HKP server instance for tests""" |