summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests/test_logs.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-22 10:09:43 -0200
committerdrebs <drebs@leap.se>2013-01-22 10:09:43 -0200
commit3359370d9ae06ffc0d60930e7f997d2331dc9037 (patch)
tree252b348a0501976e099cc45c386d95d0a05b8367 /src/leap/soledad/tests/test_logs.py
parent6fb952397573f4bc90f4cd9e72b49fcf6256e95c (diff)
parent9fc4829334e337155ef49de168e492ed7cfe58d7 (diff)
Merge branch 'feature/soledad-api' into develop
Conflicts: src/leap/soledad/__init__.py src/leap/soledad/backends/couch.py src/leap/soledad/backends/leap_backend.py src/leap/soledad/backends/objectstore.py src/leap/soledad/tests/test_couch.py src/leap/soledad/tests/test_logs.py src/leap/soledad/tests/test_sqlcipher.py src/leap/soledad/util.py
Diffstat (limited to 'src/leap/soledad/tests/test_logs.py')
-rw-r--r--src/leap/soledad/tests/test_logs.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/leap/soledad/tests/test_logs.py b/src/leap/soledad/tests/test_logs.py
index 072ac1a5..0be0d1f9 100644
--- a/src/leap/soledad/tests/test_logs.py
+++ b/src/leap/soledad/tests/test_logs.py
@@ -1,5 +1,5 @@
import unittest2 as unittest
-from leap.soledad.util import TransactionLog, SyncLog
+from leap.soledad.backends.objectstore import TransactionLog, SyncLog, ConflictLog
class LogTestCase(unittest.TestCase):
@@ -39,7 +39,7 @@ class LogTestCase(unittest.TestCase):
(1, 'tran_1'), 'error getting replica gen and trans id')
# test setting
log.set_replica_gen_and_trans_id('replica_1', 2, 'tran_12')
- self.assertEqual(len(log._log), 3, 'error in log size after setting')
+ self.assertEqual(len(log._data), 3, 'error in log size after setting')
self.assertEqual(log.get_replica_gen_and_trans_id('replica_1'),
(2, 'tran_12'), 'error setting replica gen and trans id')
self.assertEqual(log.get_replica_gen_and_trans_id('replica_2'),
@@ -49,25 +49,38 @@ class LogTestCase(unittest.TestCase):
def test_whats_changed(self):
data = [
- (2, "doc_3", "tran_3"),
- (3, "doc_2", "tran_2"),
- (1, "doc_1", "tran_1")
- ]
+ (1, "doc_1", "tran_1"),
+ (2, "doc_2", "tran_2"),
+ (3, "doc_3", "tran_3")
+ ]
log = TransactionLog()
log.log = data
self.assertEqual(
log.whats_changed(3),
- (3, "tran_2", []),
+ (3, "tran_3", []),
'error getting whats changed.')
self.assertEqual(
log.whats_changed(2),
- (3, "tran_2", [("doc_2",3,"tran_2")]),
+ (3, "tran_3", [("doc_3",3,"tran_3")]),
'error getting whats changed.')
self.assertEqual(
log.whats_changed(1),
- (3, "tran_2", [("doc_3",2,"tran_3"),("doc_2",3,"tran_2")]),
+ (3, "tran_3", [("doc_2",2,"tran_2"),("doc_3",3,"tran_3")]),
'error getting whats changed.')
+ def test_conflict_log(self):
+ # TODO: include tests for `get_conflicts` and `has_conflicts`.
+ data = [('1', 'my:1', 'irrelevant'),
+ ('2', 'my:1', 'irrelevant'),
+ ('3', 'my:1', 'irrelevant')]
+ log = ConflictLog(None)
+ log.log = data
+ log.delete_conflicts([('1','my:1'),('2','my:1')])
+ self.assertEqual(
+ log.log,
+ [('3', 'my:1', 'irrelevant')],
+ 'error deleting conflicts.')
+
if __name__ == '__main__':
unittest.main()