summaryrefslogtreecommitdiff
path: root/src/leap/soledad
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-12-04 10:42:48 -0200
committerdrebs <drebs@leap.se>2012-12-04 10:42:48 -0200
commitb4a8d6f10ebcd7d8cf284d7bd18138d074695aff (patch)
treec2463e16dbb6d2e42bb549ffb9c31bb7ab8f4bd8 /src/leap/soledad
parent26f2abf21f295700c0f8fdf3bd62667562f01ea3 (diff)
Add simple encoding test
Diffstat (limited to 'src/leap/soledad')
-rw-r--r--src/leap/soledad/leap.py2
-rw-r--r--src/leap/soledad/tests/__init__.py36
2 files changed, 37 insertions, 1 deletions
diff --git a/src/leap/soledad/leap.py b/src/leap/soledad/leap.py
index c9243587..41bcf15a 100644
--- a/src/leap/soledad/leap.py
+++ b/src/leap/soledad/leap.py
@@ -18,7 +18,7 @@ class LeapDocument(Document):
def __init__(self, doc_id=None, rev=None, json='{}', has_conflicts=False,
encrypted_json=None, default_key=None):
- super(Document, self).__init__(doc_id, rev, json, has_conflicts)
+ super(LeapDocument, self).__init__(doc_id, rev, json, has_conflicts)
if encrypted_json:
self.set_encrypted_json(encrypted_json)
self._default_key = default_key
diff --git a/src/leap/soledad/tests/__init__.py b/src/leap/soledad/tests/__init__.py
new file mode 100644
index 00000000..88cddef0
--- /dev/null
+++ b/src/leap/soledad/tests/__init__.py
@@ -0,0 +1,36 @@
+try:
+ import simplejson as json
+except ImportError:
+ import json # noqa
+
+import unittest
+import os
+
+import u1db
+from soledad import leap
+
+class EncryptedSyncTestCase(unittest.TestCase):
+
+ PREFIX = '/var/tmp'
+ db1_path = "%s/db1.u1db" % PREFIX
+ db2_path = "%s/db2.u1db" % PREFIX
+
+ def setUp(self):
+ self.db1 = u1db.open(self.db1_path, create=True,
+ document_factory=leap.LeapDocument)
+ self.db2 = u1db.open(self.db2_path, create=True,
+ document_factory=leap.LeapDocument)
+
+ def tearDown(self):
+ os.unlink(self.db1_path)
+ os.unlink(self.db2_path)
+
+ def test_encoding(self):
+ doc1 = self.db1.create_doc({ 'key' : 'val' })
+ enc1 = doc1.get_encrypted_json()
+ doc2 = leap.LeapDocument(doc_id=doc1.doc_id, json=doc1.get_json())
+ enc2 = doc2.get_encrypted_json()
+ self.assertEqual(enc1, enc2, 'incorrect document encoding')
+
+if __name__ == '__main__':
+ unittest.main()