summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/soledad/backends/couch.py6
-rw-r--r--src/leap/soledad/backends/objectstore.py2
-rw-r--r--src/leap/soledad/tests/test_couch.py47
3 files changed, 43 insertions, 12 deletions
diff --git a/src/leap/soledad/backends/couch.py b/src/leap/soledad/backends/couch.py
index 5cde4805..78026af8 100644
--- a/src/leap/soledad/backends/couch.py
+++ b/src/leap/soledad/backends/couch.py
@@ -41,10 +41,8 @@ class CouchDatabase(ObjectStore):
#-------------------------------------------------------------------------
def _get_doc(self, doc_id, check_for_conflicts=False):
- """Get just the document content, without fancy handling.
-
- Conflicts do not happen on server side, so there's no need to check
- for them.
+ """
+ Get just the document content, without fancy handling.
"""
cdoc = self._database.get(doc_id)
if cdoc is None:
diff --git a/src/leap/soledad/backends/objectstore.py b/src/leap/soledad/backends/objectstore.py
index 03694532..2ddd4c79 100644
--- a/src/leap/soledad/backends/objectstore.py
+++ b/src/leap/soledad/backends/objectstore.py
@@ -212,7 +212,7 @@ class ObjectStore(CommonBackend):
"""
NotImplementedError(self._initialize)
- def _get_u1db_data(self, u1db_data_doc_id):
+ def _get_u1db_data(self):
"""
Fetch u1db configuration data from backend storage.
"""
diff --git a/src/leap/soledad/tests/test_couch.py b/src/leap/soledad/tests/test_couch.py
index dc95f6c0..75dc1352 100644
--- a/src/leap/soledad/tests/test_couch.py
+++ b/src/leap/soledad/tests/test_couch.py
@@ -31,6 +31,8 @@ from leap.soledad.tests.u1db_tests.test_sync import (
_make_local_db_and_http_target,
_make_local_db_and_oauth_http_target,
DatabaseSyncTargetTests,
+ DatabaseSyncTests,
+ sync_via_synchronizer,
)
from leap.soledad.tests.u1db_tests.test_remote_sync_target import (
make_http_app,
@@ -58,18 +60,19 @@ class TestCouchBackendImpl(tests.TestCase):
#-----------------------------------------------------------------------------
def make_couch_database_for_test(test, replica_uid):
- return couch.CouchDatabase('http://localhost:5984', 'u1db_tests',
+ return couch.CouchDatabase('http://localhost:5984', replica_uid,
replica_uid=replica_uid or 'test')
def copy_couch_database_for_test(test, db):
- new_db = couch.CouchDatabase('http://localhost:5984', 'u1db_tests_2',
- replica_uid=db.replica_uid or 'test')
- new_db._transaction_log = copy.deepcopy(db._transaction_log)
- new_db._sync_log = copy.deepcopy(db._sync_log)
+ new_db = couch.CouchDatabase('http://localhost:5984', db._replica_uid+'_copy',
+ replica_uid=db._replica_uid or 'test')
gen, docs = db.get_all_docs(include_deleted=True)
for doc in docs:
new_db._put_doc(doc)
- new_db._ensure_u1db_data()
+ new_db._transaction_log._log = copy.deepcopy(db._transaction_log._log)
+ new_db._sync_log._log = copy.deepcopy(db._sync_log._log)
+ new_db._conflict_log._log = copy.deepcopy(db._conflict_log._log)
+ new_db._set_u1db_data()
return new_db
@@ -136,7 +139,7 @@ class CouchWithConflictsTests(LocalDatabaseWithConflictsTests):
# def tearDown(self):
# self.db.delete_database()
# super(CouchIndexTests, self).tearDown()
-#
+
#-----------------------------------------------------------------------------
@@ -182,4 +185,34 @@ class CouchDatabaseSyncTargetTests(DatabaseSyncTargetTests):
[(doc.doc_id, doc.rev), (doc2.doc_id, doc2.rev)]})
+sync_scenarios = []
+for name, scenario in COUCH_SCENARIOS:
+ scenario = dict(scenario)
+ scenario['do_sync'] = sync_via_synchronizer
+ sync_scenarios.append((name, scenario))
+ scenario = dict(scenario)
+
+#class CouchDatabaseSyncTests(DatabaseSyncTests):
+#
+# scenarios = sync_scenarios
+#
+# def setUp(self):
+# self.db = None
+# self.db1 = None
+# self.db2 = None
+# self.db3 = None
+# super(CouchDatabaseSyncTests, self).setUp()
+#
+# def tearDown(self):
+# self.db and self.db.delete_database()
+# self.db1 and self.db1.delete_database()
+# self.db2 and self.db2.delete_database()
+# self.db3 and self.db3.delete_database()
+# db = self.create_database('test1_copy', 'source')
+# db.delete_database()
+# db = self.create_database('test2_copy', 'target')
+# db.delete_database()
+# super(CouchDatabaseSyncTests, self).tearDown()
+
+
load_tests = tests.load_with_scenarios