summaryrefslogtreecommitdiffstats
path: root/ffi/lang/python/tests/test_store.py
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-02-15 18:06:50 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-11 13:23:24 +0100
commit177835be9dba392ab10994254b67aa676be66331 (patch)
tree7682b06cd40bbec88dec091c23a18002a9bfabaa /ffi/lang/python/tests/test_store.py
parented7d023d5a6a2587ba218910bc1849d0d34adca7 (diff)
ffi: Add preliminary Python bindings.
- The bingings support basic manipulation of OpenPGP data, but are quite incomplete. Furthermore, the Python API is not very pythonic in some places, so expect it to break in the future.
Diffstat (limited to 'ffi/lang/python/tests/test_store.py')
-rw-r--r--ffi/lang/python/tests/test_store.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/ffi/lang/python/tests/test_store.py b/ffi/lang/python/tests/test_store.py
new file mode 100644
index 00000000..0c86a689
--- /dev/null
+++ b/ffi/lang/python/tests/test_store.py
@@ -0,0 +1,47 @@
+from sequoia.prelude import Context, Store, Fingerprint
+
+def test_open():
+ c = Context("org.sequoia-pgp.tests", ephemeral=True)
+ Store.open(c, "default")
+
+def test_add():
+ c = Context("org.sequoia-pgp.tests", ephemeral=True)
+ s = Store.open(c, "default")
+ fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
+ s.add("Ἀριστοτέλης", fp)
+
+def test_iterate():
+ c = Context("org.sequoia-pgp.tests", ephemeral=True)
+ s = Store.open(c, "default")
+ fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
+ s.add("Ἀριστοτέλης", fp)
+ l = list(s.iter())
+ assert len(l) == 1
+ l = list(Store.list_keys(c))
+ assert len(l) == 1
+ fpi, key = l[0]
+ assert fpi == fp
+
+def test_logs():
+ c = Context("org.sequoia-pgp.tests", ephemeral=True)
+ s = Store.open(c, "default")
+ fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
+ b = s.add("Ἀριστοτέλης", fp)
+ l = list(s.iter())
+ assert len(l) == 1
+
+ # global logs
+ logs = list(Store.server_log(c))
+ assert len(logs) > 0
+
+ # per store logs
+ logs = list(s.log())
+ assert len(logs) > 0
+
+ # per binding logs
+ logs = list(b.log())
+ assert len(logs) > 0
+
+ # per key logs
+ logs = list(b.key().log())
+ assert len(logs) > 0