summaryrefslogtreecommitdiff
path: root/tests/__init__.py
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
commit43b13871c717ab7284d53ff9b8eb93742a1af362 (patch)
tree7ac52cf61a831919f6ebea79c513f583fd321572 /tests/__init__.py
parent8609766aefe111d86bae8391c719831f083c9e00 (diff)
OpenStack backend can find what's changed.
Diffstat (limited to 'tests/__init__.py')
-rw-r--r--tests/__init__.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 50c99dd4..4f63648e 100644
--- a/tests/__init__.py
+++ b/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"