diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-12 07:28:33 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-12 07:28:33 +0000 |
commit | adc9d7a9a9cd90c8d078b1276cfdad98d0303d07 (patch) | |
tree | afa49da6e1ebc85a0d16aad52591e55bda0c70f2 /rdiff-backup/testing/rorpitertest.py | |
parent | 9613406fbab1949f66fe7858590cab990c7b4b25 (diff) | |
download | rdiff-backup-adc9d7a9a9cd90c8d078b1276cfdad98d0303d07.tar.gz |
Fixed selection bug, renamed metadata files to ".snapshot"
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@278 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing/rorpitertest.py')
-rw-r--r-- | rdiff-backup/testing/rorpitertest.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/rdiff-backup/testing/rorpitertest.py b/rdiff-backup/testing/rorpitertest.py index f43a085..35f5916 100644 --- a/rdiff-backup/testing/rorpitertest.py +++ b/rdiff-backup/testing/rorpitertest.py @@ -254,6 +254,41 @@ class TreeReducerTest(unittest.TestCase): assert itm2c.root_branch.total == 12, itm2c.root_branch.total +class CacheIndexableTest(unittest.TestCase): + def get_iter(self): + """Return iterator yielding indexed objects, add to dict d""" + for i in range(100): + it = rorpiter.IndexedTuple((i,), range(i)) + self.d[(i,)] = it + yield it + + def testCaching(self): + """Test basic properties of CacheIndexable object""" + self.d = {} + + ci = rorpiter.CacheIndexable(self.get_iter(), 3) + val0 = ci.next() + val1 = ci.next() + val2 = ci.next() + + assert ci.get((1,)) == self.d[(1,)] + assert ci.get((3,)) is None + + val3 = ci.next() + val4 = ci.next() + val5 = ci.next() + + assert ci.get((3,)) == self.d[(3,)] + assert ci.get((4,)) == self.d[(4,)] + assert ci.get((1,)) is None + + def testEqual(self): + """Make sure CI doesn't alter properties of underlying iter""" + self.d = {} + l1 = list(self.get_iter()) + l2 = list(rorpiter.CacheIndexable(iter(l1), 10)) + assert l1 == l2, (l1, l2) + if __name__ == "__main__": unittest.main() |