summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-12-05 15:36:07 -0200
committerdrebs <drebs@leap.se>2012-12-05 15:36:07 -0200
commite95726b8a7803dbb23bfca470cf4b665cf8559a4 (patch)
tree3d27f83d5a1290e68763f144c87c36d7f10b982b /src/leap/soledad/tests
parentadc66753c6a98a1dbe6a41c496e71602cadfd765 (diff)
OpenStack backend can find what's changed.
Diffstat (limited to 'src/leap/soledad/tests')
-rw-r--r--src/leap/soledad/tests/__init__.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/leap/soledad/tests/__init__.py b/src/leap/soledad/tests/__init__.py
index 50c99dd4..4f63648e 100644
--- a/src/leap/soledad/tests/__init__.py
+++ b/src/leap/soledad/tests/__init__.py
@@ -8,7 +8,11 @@ import os
import u1db
from soledad import leap, GPGWrapper
-from soledad.openstack import SimpleLog, TransactionLog, SyncLog
+from soledad.openstack import (
+ SimpleLog,
+ TransactionLog,
+ SyncLog,
+ )
class EncryptedSyncTestCase(unittest.TestCase):
@@ -53,7 +57,8 @@ class LogTestCase(unittest.TestCase):
(3, "doc_2", "tran_2"),
(1, "doc_1", "tran_1")
]
- log = TransactionLog(data)
+ log = TransactionLog()
+ log.log = data
self.assertEqual(log.get_generation(), 3, 'error getting generation')
self.assertEqual(log.get_generation_info(), (3, 'tran_2'),
'error getting generation info')
@@ -70,7 +75,8 @@ class LogTestCase(unittest.TestCase):
("replica_2", 2, "tran_2"),
("replica_1", 1, "tran_1")
]
- log = SyncLog(data)
+ log = SyncLog()
+ log.log = data
# test getting
self.assertEqual(log.get_replica_gen_and_trans_id('replica_3'),
(3, 'tran_3'), 'error getting replica gen and trans id')
@@ -88,6 +94,27 @@ class LogTestCase(unittest.TestCase):
self.assertEqual(log.get_replica_gen_and_trans_id('replica_3'),
(3, 'tran_3'), 'error setting replica gen and trans id')
+ def test_whats_changed(self):
+ data = [
+ (2, "doc_3", "tran_3"),
+ (3, "doc_2", "tran_2"),
+ (1, "doc_1", "tran_1")
+ ]
+ log = TransactionLog()
+ log.log = data
+ self.assertEqual(
+ log.whats_changed(3),
+ (3, "tran_2", []),
+ 'error getting whats changed.')
+ self.assertEqual(
+ log.whats_changed(2),
+ (3, "tran_2", [("doc_2",3,"tran_2")]),
+ 'error getting whats changed.')
+ self.assertEqual(
+ log.whats_changed(1),
+ (3, "tran_2", [("doc_3",2,"tran_3"),("doc_2",3,"tran_2")]),
+ 'error getting whats changed.')
+
# Key material for testing
KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF"