summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-06-25 18:04:45 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-06-25 18:04:45 +0000
commit2caa9e388288e044183b45d18542a31fa1f4d4af (patch)
tree33af095ff4e665be96010e76cb03188e163d17a8
parentaa36fa26a216b2faf89b0bbd4d90fb16fd082f38 (diff)
downloadrdiff-backup-2caa9e388288e044183b45d18542a31fa1f4d4af.tar.gz
Added root selection test, and modified tests to jive with new
IterTreeReducer fast_process code. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@146 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/testing/lazytest.py27
-rw-r--r--rdiff-backup/testing/rpathtest.py11
-rw-r--r--rdiff-backup/testing/selectiontest.py31
-rw-r--r--rdiff-backup/testing/statisticstest.py2
4 files changed, 58 insertions, 13 deletions
diff --git a/rdiff-backup/testing/lazytest.py b/rdiff-backup/testing/lazytest.py
index d0b743c..d7cd08a 100644
--- a/rdiff-backup/testing/lazytest.py
+++ b/rdiff-backup/testing/lazytest.py
@@ -218,7 +218,7 @@ class MultiplexTest(Iterators):
assert Iter.equal(i2, self.one_to_100())
-class ITRadder(IterTreeReducer):
+class ITRBadder(ITRBranch):
def start_process(self, index):
self.total = 0
@@ -232,7 +232,7 @@ class ITRadder(IterTreeReducer):
#print "Adding subinstance ", subinstance.total
self.total += subinstance.total
-class ITRadder2(IterTreeReducer):
+class ITRBadder2(ITRBranch):
def start_process(self, index):
self.total = 0
@@ -240,6 +240,13 @@ class ITRadder2(IterTreeReducer):
#print "Adding ", self.base_index
self.total += reduce(lambda x,y: x+y, self.base_index, 0)
+ def can_fast_process(self, index):
+ if len(index) == 3: return 1
+ else: return None
+
+ def fast_process(self, index):
+ self.total += index[0] + index[1] + index[2]
+
def branch_process(self, subinstance):
#print "Adding branch ", subinstance.total
self.total += subinstance.total
@@ -257,24 +264,24 @@ class TreeReducerTest(unittest.TestCase):
def testTreeReducer(self):
"""testing IterTreeReducer"""
- itm = ITRadder()
+ itm = IterTreeReducer(ITRBadder, [])
for index in self.i1:
val = itm(index)
assert val, (val, index)
itm.Finish()
- assert itm.total == 6, itm.total
+ assert itm.root_branch.total == 6, itm.root_branch.total
- itm2 = ITRadder2()
+ itm2 = IterTreeReducer(ITRBadder2, [])
for index in self.i2:
val = itm2(index)
if index == (): assert not val
else: assert val
itm2.Finish()
- assert itm2.total == 12, itm2.total
+ assert itm2.root_branch.total == 12, itm2.root_branch.total
def testTreeReducerState(self):
"""Test saving and recreation of an IterTreeReducer"""
- itm1a = ITRadder()
+ itm1a = IterTreeReducer(ITRBadder, [])
for index in self.i1a:
val = itm1a(index)
assert val, index
@@ -283,9 +290,9 @@ class TreeReducerTest(unittest.TestCase):
val = itm1b(index)
assert val, index
itm1b.Finish()
- assert itm1b.total == 6, itm1b.total
+ assert itm1b.root_branch.total == 6, itm1b.root_branch.total
- itm2a = ITRadder2()
+ itm2a = IterTreeReducer(ITRBadder2, [])
for index in self.i2a:
val = itm2a(index)
if index == (): assert not val
@@ -301,7 +308,7 @@ class TreeReducerTest(unittest.TestCase):
if index == (): assert not val
else: assert val
itm2c.Finish()
- assert itm2c.total == 12, itm2c.total
+ assert itm2c.root_branch.total == 12, itm2c.root_branch.total
if __name__ == "__main__": unittest.main()
diff --git a/rdiff-backup/testing/rpathtest.py b/rdiff-backup/testing/rpathtest.py
index d4ffdbe..46facf2 100644
--- a/rdiff-backup/testing/rpathtest.py
+++ b/rdiff-backup/testing/rpathtest.py
@@ -371,7 +371,16 @@ class FileAttributes(FileCopying):
self.assertRaises(RPathException, RPath.copy_attribs,
self.nothing, self.nowrite)
-
+class CheckPath(unittest.TestCase):
+ """Check to make sure paths generated properly"""
+ def testpath(self):
+ """Test root paths"""
+ root = RPath(Globals.local_connection, "/")
+ assert root.path == "/", root.path
+ bin = root.append("bin")
+ assert bin.path == "/bin", bin.path
+ bin2 = RPath(Globals.local_connection, "/bin")
+ assert bin.path == "/bin", bin2.path
if __name__ == "__main__":
unittest.main()
diff --git a/rdiff-backup/testing/selectiontest.py b/rdiff-backup/testing/selectiontest.py
index 945d427..76af96f 100644
--- a/rdiff-backup/testing/selectiontest.py
+++ b/rdiff-backup/testing/selectiontest.py
@@ -224,9 +224,12 @@ testfiles/select/1/1
class ParseArgsTest(unittest.TestCase):
"""Test argument parsing"""
+ root = None
def ParseTest(self, tuplelist, indicies, filelists = []):
"""No error if running select on tuple goes over indicies"""
- self.root = DSRPath(1, Globals.local_connection, "testfiles/select")
+ if not self.root:
+ self.root = DSRPath(1, Globals.local_connection,
+ "testfiles/select")
self.Select = Select(self.root)
self.Select.ParseArgs(tuplelist, filelists)
self.Select.set_iter()
@@ -278,6 +281,32 @@ class ParseArgsTest(unittest.TestCase):
('3', '3'),
('3', '3', '2')])
+ def testGlob2(self):
+ """Test more globbing functions"""
+ self.ParseTest([("--include", "testfiles/select/*foo*/p*"),
+ ("--exclude", "**")],
+ [(), ('efools',), ('efools', 'ping'),
+ ('foobar',), ('foobar', 'pong')])
+ self.ParseTest([("--exclude", "testfiles/select/1/1/*"),
+ ("--exclude", "testfiles/select/1/2/**"),
+ ("--exclude", "testfiles/select/1/3**"),
+ ("--include", "testfiles/select/1"),
+ ("--exclude", "**")],
+ [(), ('1',), ('1', '1'), ('1', '2')])
+
+ def testAlternateRoot(self):
+ """Test select with different root"""
+ self.root = DSRPath(1, Globals.local_connection,
+ "testfiles/select/1")
+ self.ParseTest([("--exclude", "testfiles/select/1/[23]")],
+ [(), ('1',), ('1', '1'), ('1', '2'), ('1', '3')])
+
+ self.root = DSRPath(1, Globals.local_connection, "/")
+ self.ParseTest([("--exclude", "/home/*"),
+ ("--include", "/home"),
+ ("--exclude", "/")],
+ [(), ("home",)])
+
def testParseStartingFrom(self):
"""Test parse, this time starting from inside"""
self.root = DSRPath(1, Globals.local_connection, "testfiles/select")
diff --git a/rdiff-backup/testing/statisticstest.py b/rdiff-backup/testing/statisticstest.py
index 62ad0b7..032badc 100644
--- a/rdiff-backup/testing/statisticstest.py
+++ b/rdiff-backup/testing/statisticstest.py
@@ -29,7 +29,7 @@ class StatsObjTest(unittest.TestCase):
self.set_obj(s)
assert s.get_stat('SourceFiles') == 1
- s1 = StatsITR()
+ s1 = StatsITRB()
assert s1.get_stat('SourceFiles') == 0
def test_get_stats_string(self):