summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests/test_couch.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-16 09:55:27 -0200
committerdrebs <drebs@leap.se>2013-01-16 09:55:27 -0200
commite83572610574e8d3d96c0117fdb45764ffbeb538 (patch)
treeb7ab3411eb6365c242702f05c96f6d2617143e17 /src/leap/soledad/tests/test_couch.py
parent7759f6c6b862e792adb4a005d9ec27e313fb6e06 (diff)
Fix copy_database for couch tests.
Diffstat (limited to 'src/leap/soledad/tests/test_couch.py')
-rw-r--r--src/leap/soledad/tests/test_couch.py47
1 files changed, 40 insertions, 7 deletions
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