summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwgpro@gmail.com>2015-08-07 17:24:07 -0300
committerBruno Wagner <bwgpro@gmail.com>2015-08-12 17:17:19 -0300
commit7c1f5e3bcbfd881b6b1b3f258066a13ee7a4839d (patch)
treead0ea343a3a05a4fc61696671aaa9fb02274efad
parent35eda00b60d89a15930c0a6d3521e5f6afaa913e (diff)
[tests] Test sync adapted without u1db tests
Test sync now doesn't inherit from u1db tests, it's tests will now be run and were failing, so I fixed them. Sync deferred will not be correctly handled in these tests. I also pulled over a method from the u1db test and there seems to be a pattern, I'll try to deduplicate these methods as soon as it gets clearer
-rw-r--r--common/src/leap/soledad/common/tests/test_sync.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py
index 9440ae11..128b4287 100644
--- a/common/src/leap/soledad/common/tests/test_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sync.py
@@ -23,18 +23,18 @@ import time
from urlparse import urljoin
from twisted.internet import defer
+from uuid import uuid4
from testscenarios import TestWithScenarios
from leap.soledad.common import couch
-from leap.soledad.client import http_target as target
+from leap.soledad.client import http_target
from leap.soledad.client import sync
from leap.soledad.server import SoledadApp
from leap.soledad.common.tests import u1db_tests as tests
from leap.soledad.common.tests.u1db_tests import TestCaseWithServer
from leap.soledad.common.tests.u1db_tests import simple_doc
-from leap.soledad.common.tests.u1db_tests import test_sync
from leap.soledad.common.tests.util import make_token_soledad_app
from leap.soledad.common.tests.util import make_soledad_document_for_test
from leap.soledad.common.tests.util import soledad_sync_target
@@ -153,8 +153,8 @@ def make_soledad_app(state):
class TestSoledadDbSync(
TestWithScenarios,
- SoledadWithCouchServerMixin,
- test_sync.TestDbSync):
+ tests.TestCaseWithServer,
+ SoledadWithCouchServerMixin):
"""
Test db.sync remote sync shortcut
@@ -205,20 +205,18 @@ class TestSoledadDbSync(
Perform sync using SoledadSynchronizer, SoledadSyncTarget
and Token auth.
"""
- extra = {}
- extra = dict(creds={'token': {
+
+ target_url = self.getURL(target_name)
+ creds = {'token': {
'uuid': 'user-uuid',
'token': 'auth-token',
- }})
- target_url = self.getURL(target_name)
+ }}
+ target = soledad_sync_target(self, target_name)
return sync.SoledadSynchronizer(
self.db,
- target.SoledadHTTPSyncTarget(
- target_url,
- crypto=self._soledad._crypto,
- **extra)).sync(autocreate=True,
- defer_decryption=False)
+ target).sync(defer_decryption=False)
+ @defer.inlineCallbacks
def test_db_sync(self):
"""
Test sync.
@@ -229,7 +227,7 @@ class TestSoledadDbSync(
doc1 = self.db.create_doc_from_json(tests.simple_doc)
doc2 = self.db2.create_doc_from_json(tests.nested_doc)
- local_gen_before_sync = self.do_sync('test')
+ local_gen_before_sync = yield self.do_sync('test')
gen, _, changes = self.db.whats_changed(local_gen_before_sync)
self.assertEqual(1, len(changes))
self.assertEqual(doc2.doc_id, changes[0][0])
@@ -246,7 +244,7 @@ class TestSoledadDbSync(
Adapted to check for encrypted content.
"""
doc1 = self.db.create_doc_from_json(tests.simple_doc)
- local_gen_before_sync = self.do_sync('test')
+ local_gen_before_sync = yield self.do_sync('test')
gen, _, changes = self.db.whats_changed(local_gen_before_sync)
self.assertEqual(0, gen - local_gen_before_sync)
db3 = self.request_state.open_database('test')