summaryrefslogtreecommitdiff
path: root/testing/tests
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2016-11-20 15:41:21 -0300
committerdrebs <drebs@leap.se>2016-12-12 09:15:21 -0200
commitb17eecaa35240333d0270c1a3437e67510fe4f20 (patch)
treea115557030f3a6f0b1d4c089e6fac6c185d4064b /testing/tests
parentbfe330a7eaad1c51640dbbb91be233a65d2a4bd7 (diff)
[bug] emit last sent doc event
Document sending happens after encryption, so the last sent document needs to be signalled after request end.
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/sync/test_sync_target.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/tests/sync/test_sync_target.py b/testing/tests/sync/test_sync_target.py
index dd69ffa1..d02aba68 100644
--- a/testing/tests/sync/test_sync_target.py
+++ b/testing/tests/sync/test_sync_target.py
@@ -310,6 +310,37 @@ class TestSoledadSyncTarget(
self.assertGetEncryptedDoc(
db, 'doc-here', 'replica:1', '{"value": "here"}', False)
+ @defer.inlineCallbacks
+ def test_sync_exchange_send_events(self):
+ """
+ Test for sync exchange's SOLEDAD_SYNC_SEND_STATUS event.
+ """
+ remote_target = self.getSyncTarget()
+ uuid = remote_target.uuid
+ events = []
+
+ def mocked_events(*args):
+ events.append((args))
+ self.patch(
+ target.send, '_emit_send_status', mocked_events)
+
+ doc = self.make_document('doc-here', 'replica:1', '{"value": "here"}')
+ doc2 = self.make_document('doc-here', 'replica:1', '{"value": "here"}')
+ doc3 = self.make_document('doc-here', 'replica:1', '{"value": "here"}')
+ get_doc = (lambda _: doc, (1,), {})
+ get_doc2 = (lambda _: doc2, (1,), {})
+ get_doc3 = (lambda _: doc3, (1,), {})
+ docs = [(get_doc, 10, 'T-sid'),
+ (get_doc2, 11, 'T-sid2'), (get_doc3, 12, 'T-sid3')]
+ new_gen, trans_id = yield remote_target.sync_exchange(
+ docs, 'replica', last_known_generation=0,
+ last_known_trans_id=None, insert_doc_cb=lambda _: 1,
+ ensure_callback=lambda _: 1)
+ self.assertEqual(1, new_gen)
+ self.assertEqual(4, len(events))
+ self.assertEquals([(uuid, 0, 3), (uuid, 1, 3), (uuid, 2, 3),
+ (uuid, 3, 3)], events)
+
def test_sync_exchange_in_stream_error(self):
self.skipTest("bypass this test because our sync_exchange process "
"does not return u1db error 503 \"unavailable\" for "