summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-02-06 18:01:58 -0200
committerdrebs <drebs@leap.se>2013-02-06 18:03:44 -0200
commit8b9aebd6bfe95b3b6f781116910db6340eda6b95 (patch)
tree3a48cc3141fca0e9b0daf8b988d577cbd4144b41
parentc1be293ab0ad258b1febdd11a03bab105ae83739 (diff)
SQLCipher syncs using LeapSyncTarget.
-rw-r--r--backends/sqlcipher.py7
-rw-r--r--tests/test_couch.py2
-rw-r--r--tests/test_sqlcipher.py19
3 files changed, 26 insertions, 2 deletions
diff --git a/backends/sqlcipher.py b/backends/sqlcipher.py
index 6cebcf7d..354fcd31 100644
--- a/backends/sqlcipher.py
+++ b/backends/sqlcipher.py
@@ -131,8 +131,11 @@ class SQLCipherDatabase(SQLitePartialExpandDatabase):
"""
from u1db.sync import Synchronizer
from leap.soledad.backends.leap_backend import LeapSyncTarget
- return Synchronizer(self, LeapSyncTarget(url, creds=creds),
- soledad=self._soledad).sync(autocreate=autocreate)
+ return Synchronizer(
+ self,
+ LeapSyncTarget(url,
+ creds=creds,
+ soledad=self._soledad)).sync(autocreate=autocreate)
def _extra_schema_init(self, c):
c.execute(
diff --git a/tests/test_couch.py b/tests/test_couch.py
index b5d6378c..a9b2f39e 100644
--- a/tests/test_couch.py
+++ b/tests/test_couch.py
@@ -27,6 +27,8 @@ import time
import unittest
+# from: https://github.com/smcq/paisley/blob/master/paisley/test/util.py
+# TODO: include license of above project.
class CouchDBWrapper(object):
"""
Wrapper for external CouchDB instance which is started and stopped for
diff --git a/tests/test_sqlcipher.py b/tests/test_sqlcipher.py
index 0d5d00ee..b964f51e 100644
--- a/tests/test_sqlcipher.py
+++ b/tests/test_sqlcipher.py
@@ -27,6 +27,7 @@ from leap.soledad.tests import u1db_tests as tests
from leap.soledad.tests.u1db_tests import test_sqlite_backend
from leap.soledad.tests.u1db_tests import test_backends
from leap.soledad.tests.u1db_tests import test_open
+from leap.soledad.tests.u1db_tests import test_sync
PASSWORD = '123456'
@@ -322,6 +323,23 @@ class SQLCipherOpen(test_open.TestU1DBOpen):
#-----------------------------------------------------------------------------
+# The following tests come from `u1db.tests.test_sync`.
+#-----------------------------------------------------------------------------
+
+sync_scenarios = []
+for name, scenario in SQLCIPHER_SCENARIOS:
+ scenario = dict(scenario)
+ scenario['do_sync'] = test_sync.sync_via_synchronizer
+ sync_scenarios.append((name, scenario))
+ scenario = dict(scenario)
+
+
+class SQLCipherDatabaseSyncTests(test_sync.DatabaseSyncTests):
+
+ scenarios = sync_scenarios
+
+
+#-----------------------------------------------------------------------------
# Tests for actual encryption of the database
#-----------------------------------------------------------------------------
@@ -373,4 +391,5 @@ class SQLCipherEncryptionTest(unittest.TestCase):
except DatabaseIsNotEncrypted:
pass
+
load_tests = tests.load_with_scenarios