summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-12-23 06:53:18 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-12-23 06:53:18 +0000
commit9a0da726e2172321cdc1dcd21441f4ffc41e7931 (patch)
tree7f25f848386ca501b7f08c08c21af16f0d71330c /rdiff-backup/testing
parente95a61773adb2f98499cf13ff543f4249ee38226 (diff)
downloadrdiff-backup-9a0da726e2172321cdc1dcd21441f4ffc41e7931.tar.gz
Major refactoring - avoid use of 'from XX import *' in favor of more
normal 'import XXX' syntax. The previous way was an artifact from earlier versions where the whole program fit in one file. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@252 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/commontest.py52
-rw-r--r--rdiff-backup/testing/connectiontest.py15
-rw-r--r--rdiff-backup/testing/ctest.py2
-rw-r--r--rdiff-backup/testing/destructive_steppingtest.py11
-rw-r--r--rdiff-backup/testing/finaltest.py26
-rw-r--r--rdiff-backup/testing/highleveltest.py2
-rw-r--r--rdiff-backup/testing/incrementtest.py149
-rw-r--r--rdiff-backup/testing/iterfiletest.py5
-rw-r--r--rdiff-backup/testing/lazytest.py93
-rw-r--r--rdiff-backup/testing/metadatatest.py8
-rw-r--r--rdiff-backup/testing/rdifftest.py63
-rw-r--r--rdiff-backup/testing/regressiontest.py27
-rw-r--r--rdiff-backup/testing/restoretest.py30
-rw-r--r--rdiff-backup/testing/robusttest.py45
-rw-r--r--rdiff-backup/testing/rorpitertest.py258
-rw-r--r--rdiff-backup/testing/rpathtest.py48
-rw-r--r--rdiff-backup/testing/selectiontest.py37
-rw-r--r--rdiff-backup/testing/statisticstest.py30
-rw-r--r--rdiff-backup/testing/timetest.py2
19 files changed, 482 insertions, 421 deletions
diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py
index 07b6648..0f25e0d 100644
--- a/rdiff-backup/testing/commontest.py
+++ b/rdiff-backup/testing/commontest.py
@@ -1,9 +1,9 @@
"""commontest - Some functions and constants common to several test cases"""
import os, sys
-from rdiff_backup.rpath import *
-from rdiff_backup.destructive_stepping import *
-from rdiff_backup.highlevel import *
-from rdiff_backup import Globals, Hardlink, SetConnections, Main
+from rdiff_backup.log import Log
+from rdiff_backup.rpath import RPath
+from rdiff_backup import Globals, Hardlink, SetConnections, Main, \
+ selection, highlevel, lazy, Time, rpath
SourceDir = "../src"
AbsCurdir = os.getcwd() # Absolute path name of current directory
@@ -13,7 +13,7 @@ __no_execute__ = 1 # Keeps the actual rdiff-backup program from running
def Myrm(dirstring):
"""Run myrm on given directory string"""
- assert not os.system("%s/myrm %s" % (MiscDir, dirstring))
+ assert not os.system("rm -rf %s" % (dirstring,))
def Make():
"""Make sure the rdiff-backup script in the source dir is up-to-date"""
@@ -96,8 +96,8 @@ def InternalMirror(source_local, dest_local, src_dir, dest_dir):
"""
# Save attributes of root to restore later
- src_root = RPath(Globals.local_connection, src_dir)
- dest_root = RPath(Globals.local_connection, dest_dir)
+ src_root = rpath.RPath(Globals.local_connection, src_dir)
+ dest_root = rpath.RPath(Globals.local_connection, dest_dir)
dest_rbdir = dest_root.append("rdiff-backup-data")
dest_incdir = dest_rbdir.append("increments")
@@ -109,9 +109,9 @@ def InternalMirror(source_local, dest_local, src_dir, dest_dir):
InternalBackup(source_local, dest_local, src_dir, dest_dir)
dest_root.setdata()
- dest_rbdir.delete()
+ Myrm(dest_rbdir.path)
# Restore old attributes
- RPathStatic.copy_attribs(src_root, dest_root)
+ rpath.copy_attribs(src_root, dest_root)
def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time):
"""Restore mirror_dir to dest_dir at given time
@@ -133,7 +133,7 @@ def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time):
mirror_rp, dest_rp = cmd_schemas2rps([mirror_dir, dest_dir], remote_schema)
Time.setcurtime()
inc = get_increment_rp(mirror_rp, time)
- if inc: Main.restore(get_increment_rp(mirror_rp, time), dest_rp)
+ if inc: Main.Restore(get_increment_rp(mirror_rp, time), dest_rp)
else: # use alternate syntax
Main.restore_timestr = str(time)
Main.RestoreAsOf(mirror_rp, dest_rp)
@@ -173,7 +173,8 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1,
Log("Comparing %s and %s, hardlinks %s" % (src_rp.path, dest_rp.path,
compare_hardlinks), 3)
- src_select, dest_select = Select(src_rp), Select(dest_rp)
+ src_select = selection.Select(src_rp)
+ dest_select = selection.Select(dest_rp)
if ignore_tmp_files:
# Ignoring temp files can be useful when we want to check the
@@ -231,16 +232,17 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1,
Hardlink.get_indicies(dest_rorp, None)), 3)
return None
- if equality_func: result = Iter.equal(dsiter1, dsiter2, 1, equality_func)
+ if equality_func: result = lazy.Iter.equal(dsiter1, dsiter2,
+ 1, equality_func)
elif compare_hardlinks:
dsiter1 = Hardlink.add_rorp_iter(dsiter1, 1)
dsiter2 = Hardlink.add_rorp_iter(dsiter2, None)
if exclude_rbdir:
- result = Iter.equal(dsiter1, dsiter2, 1, hardlink_equal)
- else: result = Iter.equal(dsiter1, dsiter2, 1, rbdir_equal)
+ result = lazy.Iter.equal(dsiter1, dsiter2, 1, hardlink_equal)
+ else: result = lazy.Iter.equal(dsiter1, dsiter2, 1, rbdir_equal)
elif not exclude_rbdir:
- result = Iter.equal(dsiter1, dsiter2, 1, rbdir_equal)
- else: result = Iter.equal(dsiter1, dsiter2, 1)
+ result = lazy.Iter.equal(dsiter1, dsiter2, 1, rbdir_equal)
+ else: result = lazy.Iter.equal(dsiter1, dsiter2, 1)
for i in dsiter1: pass # make sure all files processed anyway
for i in dsiter2: pass
@@ -269,12 +271,12 @@ def BackupRestoreSeries(source_local, dest_local, list_of_dirnames,
"""
Globals.set('preserve_hardlinks', compare_hardlinks)
time = 10000
- dest_rp = RPath(Globals.local_connection, dest_dirname)
- restore_rp = RPath(Globals.local_connection, restore_dirname)
+ dest_rp = rpath.RPath(Globals.local_connection, dest_dirname)
+ restore_rp = rpath.RPath(Globals.local_connection, restore_dirname)
- os.system(MiscDir + "/myrm " + dest_dirname)
+ Myrm(dest_dirname)
for dirname in list_of_dirnames:
- src_rp = RPath(Globals.local_connection, dirname)
+ src_rp = rpath.RPath(Globals.local_connection, dirname)
reset_hardlink_dicts()
_reset_connections(src_rp, dest_rp)
@@ -287,10 +289,10 @@ def BackupRestoreSeries(source_local, dest_local, list_of_dirnames,
time = 10000
for dirname in list_of_dirnames[:-1]:
reset_hardlink_dicts()
- os.system(MiscDir + "/myrm " + restore_dirname)
+ Myrm(restore_dirname)
InternalRestore(dest_local, source_local, dest_dirname,
restore_dirname, time)
- src_rp = RPath(Globals.local_connection, dirname)
+ src_rp = rpath.RPath(Globals.local_connection, dirname)
assert CompareRecursive(src_rp, restore_rp)
# Restore should default back to newest time older than it
@@ -304,11 +306,11 @@ def MirrorTest(source_local, dest_local, list_of_dirnames,
dest_dirname = "testfiles/output"):
"""Mirror each of list_of_dirnames, and compare after each"""
Globals.set('preserve_hardlinks', compare_hardlinks)
- dest_rp = RPath(Globals.local_connection, dest_dirname)
+ dest_rp = rpath.RPath(Globals.local_connection, dest_dirname)
- os.system(MiscDir + "/myrm " + dest_dirname)
+ Myrm(dest_dirname)
for dirname in list_of_dirnames:
- src_rp = RPath(Globals.local_connection, dirname)
+ src_rp = rpath.RPath(Globals.local_connection, dirname)
reset_hardlink_dicts()
_reset_connections(src_rp, dest_rp)
diff --git a/rdiff-backup/testing/connectiontest.py b/rdiff-backup/testing/connectiontest.py
index 4c914fb..265862a 100644
--- a/rdiff-backup/testing/connectiontest.py
+++ b/rdiff-backup/testing/connectiontest.py
@@ -1,7 +1,7 @@
import unittest, types, tempfile, os, sys
from commontest import *
from rdiff_backup.connection import *
-from rdiff_backup import Globals
+from rdiff_backup import Globals, rpath
class LocalConnectionTest(unittest.TestCase):
"""Test the dummy connection"""
@@ -104,7 +104,7 @@ class PipeConnectionTest(unittest.TestCase):
"""Test module emulation"""
assert type(self.conn.tempfile.mktemp()) is types.StringType
assert self.conn.os.path.join("a", "b") == "a/b"
- rp1 = RPath(self.conn, self.regfilename)
+ rp1 = rpath.RPath(self.conn, self.regfilename)
assert rp1.isreg()
def testVirtualFiles(self):
@@ -112,17 +112,17 @@ class PipeConnectionTest(unittest.TestCase):
tempout = self.conn.open("testfiles/tempout", "w")
assert isinstance(tempout, VirtualFile)
regfilefp = open(self.regfilename, "r")
- RPath.copyfileobj(regfilefp, tempout)
+ rpath.copyfileobj(regfilefp, tempout)
tempout.close()
regfilefp.close()
tempoutlocal = open("testfiles/tempout", "r")
regfilefp = open(self.regfilename, "r")
- assert RPath.cmpfileobj(regfilefp, tempoutlocal)
+ assert rpath.cmpfileobj(regfilefp, tempoutlocal)
tempoutlocal.close()
regfilefp.close()
os.unlink("testfiles/tempout")
- assert RPath.cmpfileobj(self.conn.open(self.regfilename, "r"),
+ assert rpath.cmpfileobj(self.conn.open(self.regfilename, "r"),
open(self.regfilename, "r"))
def testString(self):
@@ -139,7 +139,8 @@ class PipeConnectionTest(unittest.TestCase):
def testRPaths(self):
"""Test transmission of rpaths"""
- rp = RPath(self.conn, "testfiles/various_file_types/regular_file")
+ rp = rpath.RPath(self.conn,
+ "testfiles/various_file_types/regular_file")
assert self.conn.reval("lambda rp: rp.data", rp) == rp.data
assert self.conn.reval("lambda rp: rp.conn is Globals.local_connection", rp)
@@ -192,7 +193,7 @@ class RedirectedConnectionTest(unittest.TestCase):
def testRpaths(self):
"""Test moving rpaths back and forth across connections"""
- rp = RPath(self.conna, "foo")
+ rp = rpath.RPath(self.conna, "foo")
self.connb.Globals.set("tmp_rpath", rp)
rp_returned = self.connb.Globals.get("tmp_rpath")
assert rp_returned.conn is rp.conn
diff --git a/rdiff-backup/testing/ctest.py b/rdiff-backup/testing/ctest.py
index 0233ddb..9b591fe 100644
--- a/rdiff-backup/testing/ctest.py
+++ b/rdiff-backup/testing/ctest.py
@@ -1,6 +1,6 @@
import unittest
from commontest import *
-from rdiff_backup.C import *
+from rdiff_backup import C
from rdiff_backup.rpath import *
class CTest(unittest.TestCase):
diff --git a/rdiff-backup/testing/destructive_steppingtest.py b/rdiff-backup/testing/destructive_steppingtest.py
index 7e68451..9675448 100644
--- a/rdiff-backup/testing/destructive_steppingtest.py
+++ b/rdiff-backup/testing/destructive_steppingtest.py
@@ -1,23 +1,22 @@
from __future__ import generators
import unittest
from commontest import *
-from rdiff_backup.rpath import *
-from rdiff_backup.selection import *
-from rdiff_backup import Globals
+from rdiff_backup import rpath, selection, Globals, destructive_stepping
Log.setverbosity(4)
class DSTest(unittest.TestCase):
def setUp(self):
self.lc = Globals.local_connection
- self.noperms = RPath(self.lc, "testfiles/noperms")
+ self.noperms = rpath.RPath(self.lc, "testfiles/noperms")
Globals.change_source_perms = 1
- self.iteration_dir = RPath(self.lc, "testfiles/iteration-test")
+ self.iteration_dir = rpath.RPath(self.lc, "testfiles/iteration-test")
def testDSIter(self):
"""Testing destructive stepping iterator from baserp"""
for i in range(2):
- sel = Select(DSRPath(1, self.noperms)).set_iter()
+ sel = selection.Select(destructive_stepping.
+ DSRPath(1, self.noperms)).set_iter()
ds_iter = sel.iterate_with_finalizer()
noperms = ds_iter.next()
assert noperms.isdir() and noperms.getperms() == 0, \
diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py
index 9d1f9ae..ba1128e 100644
--- a/rdiff-backup/testing/finaltest.py
+++ b/rdiff-backup/testing/finaltest.py
@@ -1,13 +1,11 @@
-import unittest, os, re, sys
+import unittest, os, re, sys, time
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.rpath import *
-from rdiff_backup import Globals
+from rdiff_backup import Globals, log, rpath
"""Regression tests"""
Globals.exclude_mirror_regexps = [re.compile(".*/rdiff-backup-data")]
-Log.setverbosity(7)
+log.Log.setverbosity(7)
lc = Globals.local_connection
@@ -15,7 +13,7 @@ class Local:
"""This is just a place to put increments relative to the local
connection"""
def get_local_rp(extension):
- return RPath(Globals.local_connection, "testfiles/" + extension)
+ return rpath.RPath(Globals.local_connection, "testfiles/" + extension)
vftrp = get_local_rp('various_file_types')
inc1rp = get_local_rp('increment1')
@@ -154,7 +152,7 @@ class PathSetter(unittest.TestCase):
"testfiles/output/rdiff-backup-data/increments")
self.exec_rb(None, timbar_paths[0])
self.refresh(Local.timbar_in, Local.timbar_out)
- assert RPath.cmp_with_attribs(Local.timbar_in, Local.timbar_out)
+ assert rpath.cmp_with_attribs(Local.timbar_in, Local.timbar_out)
self.exec_rb_restore(25000, 'testfiles/output/various_file_types',
'testfiles/vft2_out')
@@ -173,8 +171,8 @@ class PathSetter(unittest.TestCase):
incfiles = filter(lambda s: s.startswith(basename),
os.listdir(directory))
incfiles.sort()
- incrps = map(lambda f: RPath(lc, directory+"/"+f), incfiles)
- return map(lambda x: x.path, filter(RPath.isincfile, incrps))
+ incrps = map(lambda f: rpath.RPath(lc, directory+"/"+f), incfiles)
+ return map(lambda x: x.path, filter(rpath.RPath.isincfile, incrps))
class Final(PathSetter):
@@ -287,7 +285,7 @@ testfiles/increment2/changed_dir""")
"testfiles/output/changed_dir/foo")
# Test selective restoring
- mirror_rp = RPath(Globals.local_connection, "testfiles/output")
+ mirror_rp = rpath.RPath(Globals.local_connection, "testfiles/output")
restore_filename = get_increment_rp(mirror_rp, 10000).path
assert not os.system(self.rb_schema +
"--include testfiles/restoretarget1/various_file_types/"
@@ -321,8 +319,8 @@ testfiles/increment2/changed_dir""")
# Make an exclude list
os.mkdir("testfiles/vft_out")
- excluderp = RPath(Globals.local_connection,
- "testfiles/vft_out/exclude")
+ excluderp = rpath.RPath(Globals.local_connection,
+ "testfiles/vft_out/exclude")
fp = excluderp.open("w")
fp.write("""
../testfiles/various_file_types/regular_file
@@ -331,8 +329,8 @@ testfiles/increment2/changed_dir""")
assert not fp.close()
# Make an include list
- includerp = RPath(Globals.local_connection,
- "testfiles/vft_out/include")
+ includerp = rpath.RPath(Globals.local_connection,
+ "testfiles/vft_out/include")
fp = includerp.open("w")
fp.write("""
../testfiles/various_file_types/executable
diff --git a/rdiff-backup/testing/highleveltest.py b/rdiff-backup/testing/highleveltest.py
index 92490a4..2f1d937 100644
--- a/rdiff-backup/testing/highleveltest.py
+++ b/rdiff-backup/testing/highleveltest.py
@@ -6,7 +6,7 @@ class RemoteMirrorTest(unittest.TestCase):
"""Test mirroring"""
def setUp(self):
"""Start server"""
- Log.setverbosity(7)
+ Log.setverbosity(3)
Globals.change_source_perms = 1
SetConnections.UpdateGlobal('checkpoint_interval', 3)
diff --git a/rdiff-backup/testing/incrementtest.py b/rdiff-backup/testing/incrementtest.py
index 45519e5..0aa52ea 100644
--- a/rdiff-backup/testing/incrementtest.py
+++ b/rdiff-backup/testing/incrementtest.py
@@ -1,15 +1,14 @@
-import unittest, os
+import unittest, os, re, time
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.rpath import *
-from rdiff_backup.restore import *
+from rdiff_backup import log, rpath, restore, increment, Time, \
+ Rdiff, statistics
lc = Globals.local_connection
Globals.change_source_perms = 1
Log.setverbosity(3)
def getrp(ending):
- return RPath(lc, "testfiles/various_file_types/" + ending)
+ return rpath.RPath(lc, "testfiles/various_file_types/" + ending)
rf = getrp("regular_file")
rf2 = getrp("two_hardlinked_files1")
@@ -22,11 +21,11 @@ dir = getrp(".")
sym = getrp("symbolic_link")
nothing = getrp("nothing")
-target = RPath(lc, "testfiles/out")
-out2 = RPath(lc, "testfiles/out2")
-out_gz = RPath(lc, "testfiles/out.gz")
+target = rpath.RPath(lc, "testfiles/out")
+out2 = rpath.RPath(lc, "testfiles/out2")
+out_gz = rpath.RPath(lc, "testfiles/out.gz")
-Time.setprevtime(999424113.24931)
+Time.setprevtime(999424113)
prevtimestr = "2001-09-02T02:48:33-07:00"
t_pref = "testfiles/out.2001-09-02T02:48:33-07:00"
t_diff = "testfiles/out.2001-09-02T02:48:33-07:00.diff"
@@ -39,78 +38,72 @@ class inctest(unittest.TestCase):
def setUp(self):
Globals.set('isbackup_writer',1)
+ def check_time(self, rp):
+ """Make sure that rp is an inc file, and time is Time.prevtime"""
+ assert rp.isincfile(), rp
+ t = Time.stringtotime(rp.getinctime())
+ assert t == Time.prevtime, (t, Time.prevtime)
+
def testreg(self):
"""Test increment of regular files"""
Globals.compression = None
target.setdata()
if target.lstat(): target.delete()
- rpd = RPath(lc, t_diff)
+ rpd = rpath.RPath(lc, t_diff)
if rpd.lstat(): rpd.delete()
- Inc.Increment(rf, exec1, target)
- rpd.setdata()
- assert rpd.isreg(), rpd
- assert RPath.cmp_attribs(rpd, exec1)
- rpd.delete()
+ diffrp = increment.Increment(rf, exec1, target)
+ assert diffrp.isreg(), diffrp
+ assert rpath.cmp_attribs(diffrp, exec1)
+ self.check_time(diffrp)
+ assert diffrp.getinctype() == 'diff', diffrp.getinctype()
+ diffrp.delete()
def testmissing(self):
"""Test creation of missing files"""
- Inc.Increment(rf, nothing, target)
- rp = RPath(lc, t_pref + ".missing")
- assert rp.lstat()
- rp.delete()
+ missing_rp = increment.Increment(rf, nothing, target)
+ self.check_time(missing_rp)
+ assert missing_rp.getinctype() == 'missing'
+ missing_rp.delete()
def testsnapshot(self):
"""Test making of a snapshot"""
Globals.compression = None
- rp = RPath(lc, t_pref + ".snapshot")
- if rp.lstat(): rp.delete()
- Inc.Increment(rf, sym, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, sym)
- assert RPath.cmp(rp, sym)
- rp.delete()
-
- rp = RPath(lc, t_pref + ".snapshot")
- if rp.lstat(): rp.delete()
- Inc.Increment(sym, rf, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, rf)
- assert RPath.cmp(rp, rf)
- rp.delete()
+ snap_rp = increment.Increment(rf, sym, target)
+ self.check_time(snap_rp)
+ assert rpath.cmp_attribs(snap_rp, sym)
+ assert rpath.cmp(snap_rp, sym)
+ snap_rp.delete()
+
+ snap_rp2 = increment.Increment(sym, rf, target)
+ self.check_time(snap_rp2)
+ assert rpath.cmp_attribs(snap_rp2, rf)
+ assert rpath.cmp(snap_rp2, rf)
+ snap_rp2.delete()
def testGzipsnapshot(self):
"""Test making a compressed snapshot"""
Globals.compression = 1
- rp = RPath(lc, t_pref + ".snapshot")
- if rp.lstat(): rp.delete()
- Inc.Increment(rf, sym, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, sym)
- assert RPath.cmp(rp, sym)
+ rp = increment.Increment(rf, sym, target)
+ self.check_time(rp)
+ assert rpath.cmp_attribs(rp, sym)
+ assert rpath.cmp(rp, sym)
rp.delete()
- rp = RPath(lc, t_pref + ".snapshot.gz")
- if rp.lstat(): rp.delete()
- Inc.Increment(sym, rf, target)
- rp.setdata()
-
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, rf)
- assert RPath.cmpfileobj(rp.open("rb", 1), rf.open("rb"))
+ rp = increment.Increment(sym, rf, target)
+ self.check_time(rp)
+ assert rpath.cmp_attribs(rp, rf)
+ assert rpath.cmpfileobj(rp.open("rb", 1), rf.open("rb"))
+ assert rp.isinccompressed()
rp.delete()
def testdir(self):
"""Test increment on dir"""
- Inc.Increment(sym, dir, target)
- rp = RPath(lc, t_pref + ".dir")
- rp2 = RPath(lc, t_pref)
+ rp = increment.Increment(sym, dir, target)
+ self.check_time(rp)
assert rp.lstat()
assert target.isdir()
- assert RPath.cmp_attribs(dir, rp)
+ assert rpath.cmp_attribs(dir, rp)
assert rp.isreg()
rp.delete()
target.delete()
@@ -118,46 +111,36 @@ class inctest(unittest.TestCase):
def testDiff(self):
"""Test making diffs"""
Globals.compression = None
- rp = RPath(lc, t_pref + '.diff')
- if rp.lstat(): rp.delete()
- Inc.Increment(rf, rf2, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, rf2)
+ rp = increment.Increment(rf, rf2, target)
+ self.check_time(rp)
+ assert rpath.cmp_attribs(rp, rf2)
Rdiff.patch_action(rf, rp, out2).execute()
- assert RPath.cmp(rf2, out2)
+ assert rpath.cmp(rf2, out2)
rp.delete()
out2.delete()
def testGzipDiff(self):
"""Test making gzipped diffs"""
Globals.compression = 1
- rp = RPath(lc, t_pref + '.diff.gz')
- if rp.lstat(): rp.delete()
- Inc.Increment(rf, rf2, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, rf2)
+ rp = increment.Increment(rf, rf2, target)
+ self.check_time(rp)
+ assert rpath.cmp_attribs(rp, rf2)
Rdiff.patch_action(rf, rp, out2, delta_compressed = 1).execute()
- assert RPath.cmp(rf2, out2)
+ assert rpath.cmp(rf2, out2)
rp.delete()
out2.delete()
def testGzipRegexp(self):
"""Here a .gz file shouldn't be compressed"""
Globals.compression = 1
- RPath.copy(rf, out_gz)
+ rpath.copy(rf, out_gz)
assert out_gz.lstat()
- rp = RPath(lc, t_pref + '.diff')
- if rp.lstat(): rp.delete()
-
- Inc.Increment(rf, out_gz, target)
- rp.setdata()
- assert rp.lstat()
- assert RPath.cmp_attribs(rp, out_gz)
+ rp = increment.Increment(rf, out_gz, target)
+ self.check_time(rp)
+ assert rpath.cmp_attribs(rp, out_gz)
Rdiff.patch_action(rf, rp, out2).execute()
- assert RPath.cmp(out_gz, out2)
+ assert rpath.cmp(out_gz, out2)
rp.delete()
out2.delete()
out_gz.delete()
@@ -194,8 +177,8 @@ class inctest2(unittest.TestCase):
InternalBackup(1, 1, "testfiles/stattest2", "testfiles/output",
time.time()+1)
- rbdir = RPath(Globals.local_connection,
- "testfiles/output/rdiff-backup-data")
+ rbdir = rpath.RPath(Globals.local_connection,
+ "testfiles/output/rdiff-backup-data")
#incs = Restore.get_inclist(rbdir.append("subdir").
# append("directory_statistics"))
@@ -217,14 +200,14 @@ class inctest2(unittest.TestCase):
#assert 400000 < subdir_stats.ChangedMirrorSize < 420000
#assert 10 < subdir_stats.IncrementFileSize < 20000
- incs = Restore.get_inclist(rbdir.append("session_statistics"))
+ incs = restore.get_inclist(rbdir.append("session_statistics"))
assert len(incs) == 2
- s2 = StatsObj().read_stats_from_rp(incs[0])
+ s2 = statistics.StatsObj().read_stats_from_rp(incs[0])
assert s2.SourceFiles == 7
assert 700000 < s2.SourceFileSize < 750000
self.stats_check_initial(s2)
- root_stats = StatsObj().read_stats_from_rp(incs[1])
+ root_stats = statistics.StatsObj().read_stats_from_rp(incs[1])
assert root_stats.SourceFiles == 7, root_stats.SourceFiles
assert 550000 < root_stats.SourceFileSize < 570000
assert root_stats.MirrorFiles == 7
diff --git a/rdiff-backup/testing/iterfiletest.py b/rdiff-backup/testing/iterfiletest.py
index 2d9fa58..63975d0 100644
--- a/rdiff-backup/testing/iterfiletest.py
+++ b/rdiff-backup/testing/iterfiletest.py
@@ -1,6 +1,7 @@
import unittest, StringIO
from commontest import *
from rdiff_backup.iterfile import *
+from rdiff_backup import lazy
class testIterFile(unittest.TestCase):
@@ -11,8 +12,8 @@ class testIterFile(unittest.TestCase):
def testConversion(self):
"""Test iter to file conversion"""
for itm in [self.iter1maker, self.iter2maker]:
- assert Iter.equal(itm(),
- IterWrappingFile(FileWrappingIter(itm())))
+ assert lazy.Iter.equal(itm(),
+ IterWrappingFile(FileWrappingIter(itm())))
class testBufferedRead(unittest.TestCase):
def testBuffering(self):
diff --git a/rdiff-backup/testing/lazytest.py b/rdiff-backup/testing/lazytest.py
index f1949a7..99bd148 100644
--- a/rdiff-backup/testing/lazytest.py
+++ b/rdiff-backup/testing/lazytest.py
@@ -218,97 +218,4 @@ class MultiplexTest(Iterators):
assert Iter.equal(i2, self.one_to_100())
-class ITRBadder(ITRBranch):
- def start_process(self, index):
- self.total = 0
-
- def end_process(self):
- if self.base_index:
- summand = self.base_index[-1]
- #print "Adding ", summand
- self.total += summand
-
- def branch_process(self, subinstance):
- #print "Adding subinstance ", subinstance.total
- self.total += subinstance.total
-
-class ITRBadder2(ITRBranch):
- def start_process(self, index):
- self.total = 0
-
- def end_process(self):
- #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
-
-class TreeReducerTest(unittest.TestCase):
- def setUp(self):
- self.i1 = [(), (1,), (2,), (3,)]
- self.i2 = [(0,), (0,1), (0,1,0), (0,1,1), (0,2), (0,2,1), (0,3)]
-
- self.i1a = [(), (1,)]
- self.i1b = [(2,), (3,)]
- self.i2a = [(0,), (0,1), (0,1,0)]
- self.i2b = [(0,1,1), (0,2)]
- self.i2c = [(0,2,1), (0,3)]
-
- def testTreeReducer(self):
- """testing IterTreeReducer"""
- itm = IterTreeReducer(ITRBadder, [])
- for index in self.i1:
- val = itm(index)
- assert val, (val, index)
- itm.Finish()
- assert itm.root_branch.total == 6, itm.root_branch.total
-
- itm2 = IterTreeReducer(ITRBadder2, [])
- for index in self.i2:
- val = itm2(index)
- if index == (): assert not val
- else: assert val
- itm2.Finish()
- assert itm2.root_branch.total == 12, itm2.root_branch.total
-
- def testTreeReducerState(self):
- """Test saving and recreation of an IterTreeReducer"""
- itm1a = IterTreeReducer(ITRBadder, [])
- for index in self.i1a:
- val = itm1a(index)
- assert val, index
- itm1b = pickle.loads(pickle.dumps(itm1a))
- for index in self.i1b:
- val = itm1b(index)
- assert val, index
- itm1b.Finish()
- assert itm1b.root_branch.total == 6, itm1b.root_branch.total
-
- itm2a = IterTreeReducer(ITRBadder2, [])
- for index in self.i2a:
- val = itm2a(index)
- if index == (): assert not val
- else: assert val
- itm2b = pickle.loads(pickle.dumps(itm2a))
- for index in self.i2b:
- val = itm2b(index)
- if index == (): assert not val
- else: assert val
- itm2c = pickle.loads(pickle.dumps(itm2b))
- for index in self.i2c:
- val = itm2c(index)
- if index == (): assert not val
- else: assert val
- itm2c.Finish()
- assert itm2c.root_branch.total == 12, itm2c.root_branch.total
-
-
if __name__ == "__main__": unittest.main()
diff --git a/rdiff-backup/testing/metadatatest.py b/rdiff-backup/testing/metadatatest.py
index 7211c67..570dd79 100644
--- a/rdiff-backup/testing/metadatatest.py
+++ b/rdiff-backup/testing/metadatatest.py
@@ -1,6 +1,7 @@
import unittest, os, cStringIO, time
from rdiff_backup.metadata import *
-from rdiff_backup import rpath, Globals, selection, destructive_stepping
+from rdiff_backup import rpath, connection, Globals, selection, \
+ destructive_stepping
tempdir = rpath.RPath(Globals.local_connection, "testfiles/output")
@@ -61,9 +62,8 @@ class MetadataTest(unittest.TestCase):
if temprp.lstat(): return temprp
self.make_temp()
- root = rpath.RPath(Globals.local_connection, "testfiles/bigdir")
- dsrp_root = destructive_stepping.DSRPath(1, root)
- rpath_iter = selection.Select(dsrp_root).set_iter()
+ rootrp = rpath.RPath(Globals.local_connection, "testfiles/bigdir")
+ rpath_iter = selection.Select(rootrp).set_iter()
start_time = time.time()
OpenMetadata(temprp)
diff --git a/rdiff-backup/testing/rdifftest.py b/rdiff-backup/testing/rdifftest.py
index 9de20a3..999f1ac 100644
--- a/rdiff-backup/testing/rdifftest.py
+++ b/rdiff-backup/testing/rdifftest.py
@@ -1,8 +1,6 @@
import unittest, random
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.selection import *
-from rdiff_backup import Globals, Rdiff
+from rdiff_backup import Globals, Rdiff, selection, log, rpath
Log.setverbosity(6)
@@ -19,18 +17,19 @@ def MakeRandomFile(path):
class RdiffTest(unittest.TestCase):
"""Test rdiff"""
lc = Globals.local_connection
- basis = RPath(lc, "testfiles/basis")
- new = RPath(lc, "testfiles/new")
- output = RPath(lc, "testfiles/output")
- delta = RPath(lc, "testfiles/delta")
- signature = RPath(lc, "testfiles/signature")
+ basis = rpath.RPath(lc, "testfiles/basis")
+ new = rpath.RPath(lc, "testfiles/new")
+ output = rpath.RPath(lc, "testfiles/output")
+ delta = rpath.RPath(lc, "testfiles/delta")
+ signature = rpath.RPath(lc, "testfiles/signature")
def testRdiffSig(self):
"""Test making rdiff signatures"""
- sig = RPath(self.lc, "testfiles/various_file_types/regular_file.sig")
+ sig = rpath.RPath(self.lc,
+ "testfiles/various_file_types/regular_file.sig")
sigfp = sig.open("r")
rfsig = Rdiff.get_signature(RPath(self.lc, "testfiles/various_file_types/regular_file"))
- assert RPath.cmpfileobj(sigfp, rfsig)
+ assert rpath.cmpfileobj(sigfp, rfsig)
sigfp.close()
rfsig.close()
@@ -44,7 +43,7 @@ class RdiffTest(unittest.TestCase):
for i in range(2):
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, [self.basis, self.new])
+ map(rpath.RPath.setdata, [self.basis, self.new])
assert self.basis.lstat() and self.new.lstat()
self.signature.write_from_fileobj(Rdiff.get_signature(self.basis))
assert self.signature.lstat()
@@ -52,8 +51,8 @@ class RdiffTest(unittest.TestCase):
self.new))
assert self.delta.lstat()
Rdiff.patch_action(self.basis, self.delta, self.output).execute()
- assert RPath.cmp(self.new, self.output)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.new, self.output)
+ map(rpath.RPath.delete, rplist)
def testRdiffDeltaPatchGzip(self):
"""Same as above by try gzipping patches"""
@@ -64,7 +63,7 @@ class RdiffTest(unittest.TestCase):
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, [self.basis, self.new])
+ map(rpath.RPath.setdata, [self.basis, self.new])
assert self.basis.lstat() and self.new.lstat()
self.signature.write_from_fileobj(Rdiff.get_signature(self.basis))
assert self.signature.lstat()
@@ -77,8 +76,8 @@ class RdiffTest(unittest.TestCase):
Rdiff.patch_action(self.basis, self.delta, self.output,
delta_compressed = 1).execute()
- assert RPath.cmp(self.new, self.output)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.new, self.output)
+ map(rpath.RPath.delete, rplist)
def testWriteDelta(self):
"""Test write delta feature of rdiff"""
@@ -86,23 +85,23 @@ class RdiffTest(unittest.TestCase):
rplist = [self.basis, self.new, self.delta, self.output]
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, [self.basis, self.new])
+ map(rpath.RPath.setdata, [self.basis, self.new])
assert self.basis.lstat() and self.new.lstat()
Rdiff.write_delta(self.basis, self.new, self.delta)
assert self.delta.lstat()
Rdiff.patch_action(self.basis, self.delta, self.output).execute()
- assert RPath.cmp(self.new, self.output)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.new, self.output)
+ map(rpath.RPath.delete, rplist)
def testWriteDeltaGzip(self):
"""Same as above but delta is written gzipped"""
rplist = [self.basis, self.new, self.delta, self.output]
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, [self.basis, self.new])
+ map(rpath.RPath.setdata, [self.basis, self.new])
assert self.basis.lstat() and self.new.lstat()
- delta_gz = RPath(self.delta.conn, self.delta.path + ".gz")
+ delta_gz = rpath.RPath(self.delta.conn, self.delta.path + ".gz")
if delta_gz.lstat(): delta_gz.delete()
Rdiff.write_delta(self.basis, self.new, delta_gz, 1)
@@ -111,8 +110,8 @@ class RdiffTest(unittest.TestCase):
delta_gz.setdata()
self.delta.setdata()
Rdiff.patch_action(self.basis, self.delta, self.output).execute()
- assert RPath.cmp(self.new, self.output)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.new, self.output)
+ map(rpath.RPath.delete, rplist)
def testRdiffRename(self):
"""Rdiff replacing original file with patch outfile"""
@@ -122,7 +121,7 @@ class RdiffTest(unittest.TestCase):
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, [self.basis, self.new])
+ map(rpath.RPath.setdata, [self.basis, self.new])
assert self.basis.lstat() and self.new.lstat()
self.signature.write_from_fileobj(Rdiff.get_signature(self.basis))
assert self.signature.lstat()
@@ -130,8 +129,8 @@ class RdiffTest(unittest.TestCase):
self.new))
assert self.delta.lstat()
Rdiff.patch_action(self.basis, self.delta).execute()
- assert RPath.cmp(self.basis, self.new)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.basis, self.new)
+ map(rpath.RPath.delete, rplist)
def testCopy(self):
"""Using rdiff to copy two files"""
@@ -141,10 +140,10 @@ class RdiffTest(unittest.TestCase):
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
- map(RPath.setdata, rplist)
+ map(rpath.RPath.setdata, rplist)
Rdiff.copy_action(self.basis, self.new).execute()
- assert RPath.cmp(self.basis, self.new)
- map(RPath.delete, rplist)
+ assert rpath.cmp(self.basis, self.new)
+ map(rpath.RPath.delete, rplist)
def testPatchWithAttribs(self):
"""Using rdiff to copy two files with attributes"""
@@ -155,9 +154,9 @@ class RdiffTest(unittest.TestCase):
MakeRandomFile(self.basis.path)
MakeRandomFile(self.new.path)
self.new.chmod(0401)
- map(RPath.setdata, rplist)
+ map(rpath.RPath.setdata, rplist)
Rdiff.write_delta(self.basis, self.new, self.delta)
- RPath.copy_attribs(self.new, self.delta)
+ rpath.copy_attribs(self.new, self.delta)
assert self.delta.getperms() == 0401
assert not self.basis == self.new
@@ -165,7 +164,7 @@ class RdiffTest(unittest.TestCase):
if not self.basis == self.new:
print self.basis, self.new
assert 0
- map(RPath.delete, rplist)
+ map(rpath.RPath.delete, rplist)
if __name__ == '__main__':
diff --git a/rdiff-backup/testing/regressiontest.py b/rdiff-backup/testing/regressiontest.py
index e881b63..0391f95 100644
--- a/rdiff-backup/testing/regressiontest.py
+++ b/rdiff-backup/testing/regressiontest.py
@@ -1,8 +1,6 @@
import unittest, os
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.rpath import *
-from rdiff_backup import Globals, SetConnections
+from rdiff_backup import Globals, SetConnections, log, rpath
"""Regression tests
@@ -14,13 +12,13 @@ testfiles
Globals.set('change_source_perms', 1)
Globals.counter = 0
-Log.setverbosity(7)
+log.Log.setverbosity(7)
class Local:
"""This is just a place to put increments relative to the local
connection"""
def get_local_rp(extension):
- return RPath(Globals.local_connection, "testfiles/" + extension)
+ return rpath.RPath(Globals.local_connection, "testfiles/" + extension)
inc1rp = get_local_rp('increment1')
inc2rp = get_local_rp('increment2')
@@ -55,10 +53,10 @@ class PathSetter(unittest.TestCase):
else: return ('./', Globals.local_connection)
def get_src_rp(self, path):
- return RPath(self.src_conn, self.src_prefix + path)
+ return rpath.RPath(self.src_conn, self.src_prefix + path)
def get_dest_rp(self, path):
- return RPath(self.dest_conn, self.dest_prefix + path)
+ return rpath.RPath(self.dest_conn, self.dest_prefix + path)
def set_rbdir(self, rpout):
"""Create rdiff-backup-data dir if not already, tell everyone"""
@@ -89,9 +87,10 @@ class PathSetter(unittest.TestCase):
self.get_prefix_and_conn(dest_path, dest_return)
SetConnections.BackupInitConnections(self.src_conn, self.dest_conn)
- os.system(MiscDir+"/myrm testfiles/output* testfiles/restoretarget* "
- "testfiles/noperms_output testfiles/root_output "
- "testfiles/unreadable_out")
+ assert not os.system("rm -rf testfiles/output* "
+ "testfiles/restoretarget* "
+ "testfiles/noperms_output testfiles/root_output "
+ "testfiles/unreadable_out")
self.inc1rp = self.get_src_rp("testfiles/increment1")
self.inc2rp = self.get_src_rp('testfiles/increment2')
@@ -157,7 +156,7 @@ class IncrementTest1(unittest.TestCase):
class IncrementTest2(PathSetter):
def OldtestRecoveryLocal(self):
"""Test to see if rdiff-backup can continue with bad increment"""
- os.system(MiscDir+'/myrm testfiles/recovery_out_backup')
+ assert not os.system("rm -rf testfiles/recovery_out_backup")
self.setPathnames(None, None, None, None)
Time.setprevtime(1006136450)
Time.setcurtime()
@@ -174,7 +173,7 @@ class IncrementTest2(PathSetter):
def OldtestRecoveryRemote(self):
"""Test Recovery with both connections remote"""
- os.system(MiscDir+'/myrm testfiles/recovery_out_backup')
+ assert not os.system('rm -rf testfiles/recovery_out_backup')
self.setPathnames('test1', '../', 'test2/tmp', '../../')
Time.setprevtime(1006136450)
Time.setcurtime()
@@ -360,7 +359,7 @@ class MirrorTest(PathSetter):
Globals.change_source_perms = 1
def deleteoutput(self):
- os.system(MiscDir+"/myrm testfiles/output*")
+ assert not os.system("rm -rf testfiles/output*")
self.rbdir = self.rpout.append('rdiff-backup-data')
self.rpout.mkdir()
self.rbdir.mkdir()
@@ -395,7 +394,7 @@ class MirrorTest(PathSetter):
Time.setcurtime()
SaveState.init_filenames()
self.Mirror(self.inc1rp, self.rpout)
- #RPath.copy_attribs(self.inc1rp, self.rpout)
+ #rpath.RPath.copy_attribs(self.inc1rp, self.rpout)
assert CompareRecursive(Local.inc1rp, Local.rpout)
self.Mirror(self.inc2rp, self.rpout)
diff --git a/rdiff-backup/testing/restoretest.py b/rdiff-backup/testing/restoretest.py
index 9d7d9a9..6198ccb 100644
--- a/rdiff-backup/testing/restoretest.py
+++ b/rdiff-backup/testing/restoretest.py
@@ -1,8 +1,6 @@
import unittest
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.restore import *
-from rdiff_backup import Globals
+from rdiff_backup import log, restore, Globals, rpath
Log.setverbosity(3)
@@ -23,26 +21,26 @@ class RestoreTest(unittest.TestCase):
dirlist = os.listdir(self.prefix)
dirlist.sort()
baselist = filter(lambda f: f.startswith(basename), dirlist)
- rps = map(lambda f: RPath(lc, self.prefix+f), baselist)
+ rps = map(lambda f: rpath.RPath(lc, self.prefix+f), baselist)
incs = filter(lambda rp: rp.isincfile(), rps)
- tuples = map(lambda rp: (rp, RPath(lc, "%s.%s" %
- (rp.getincbase().path,
- rp.getinctime()))),
+ tuples = map(lambda rp: (rp, rpath.RPath(lc, "%s.%s" %
+ (rp.getincbase().path,
+ rp.getinctime()))),
incs)
return tuples, incs
def restoreonefiletest(self, basename):
tuples, incs = self.maketesttuples(basename)
- rpbase = RPath(lc, self.prefix + basename)
- rptarget = RPath(lc, "testfiles/outfile")
+ rpbase = rpath.RPath(lc, self.prefix + basename)
+ rptarget = rpath.RPath(lc, "testfiles/outfile")
for pair in tuples:
print "Processing file " + pair[0].path
if rptarget.lstat(): rptarget.delete()
rest_time = Time.stringtotime(pair[0].getinctime())
- rid = RestoreIncrementData((), rpbase, incs)
+ rid = restore.RestoreIncrementData((), rpbase, incs)
rid.sortincseq(rest_time, 10000000000) # pick some really late time
- rcd = RestoreCombinedData(rid, rpbase, rptarget)
+ rcd = restore.RestoreCombinedData(rid, rpbase, rptarget)
rcd.RestoreFile()
#sorted_incs = Restore.sortincseq(rest_time, incs)
#Restore.RestoreFile(rest_time, rpbase, (), sorted_incs, rptarget)
@@ -50,9 +48,9 @@ class RestoreTest(unittest.TestCase):
if not rptarget.lstat(): assert not pair[1].lstat()
elif not pair[1].lstat(): assert not rptarget.lstat()
else:
- assert RPath.cmp(rptarget, pair[1]), \
+ assert rpath.cmp(rptarget, pair[1]), \
"%s %s" % (rptarget.path, pair[1].path)
- assert RPath.cmp_attribs(rptarget, pair[1]), \
+ assert rpath.cmp_attribs(rptarget, pair[1]), \
"%s %s" % (rptarget.path, pair[1].path)
rptarget.delete()
@@ -75,7 +73,7 @@ class RestoreTest(unittest.TestCase):
for inc, incbase in tuples:
assert inc.isincfile()
inctime = Time.stringtotime(inc.getinctime())
- rid1 = RestoreIncrementData(basename, incbase, incs)
+ rid1 = restore.RestoreIncrementData(basename, incbase, incs)
rid1.sortincseq(inctime, mirror_time)
assert rid1.inc_list, rid1.inc_list
# oldest increment should be exactly inctime
@@ -97,8 +95,8 @@ class RestoreTest(unittest.TestCase):
InternalRestore(1, 1, "testfiles/restoretest3",
"testfiles/output", 20000)
- src_rp = RPath(Globals.local_connection, "testfiles/increment2")
- restore_rp = RPath(Globals.local_connection, "testfiles/output")
+ src_rp = rpath.RPath(Globals.local_connection, "testfiles/increment2")
+ restore_rp = rpath.RPath(Globals.local_connection, "testfiles/output")
assert CompareRecursive(src_rp, restore_rp)
def testRestoreCorrupt(self):
diff --git a/rdiff-backup/testing/robusttest.py b/rdiff-backup/testing/robusttest.py
index 199f317..8c6d51c 100644
--- a/rdiff-backup/testing/robusttest.py
+++ b/rdiff-backup/testing/robusttest.py
@@ -1,14 +1,13 @@
import os, unittest
from commontest import *
-from rdiff_backup.rpath import *
-from rdiff_backup.robust import *
+from rdiff_backup import rpath, robust, TempFile, Globals
class TestRobustAction(unittest.TestCase):
"""Test some robust actions"""
def testCopyWithAttribs(self):
"""Test copy with attribs action"""
- rpin = RPath(Globals.local_connection, "./testfiles/robust/in")
+ rpin = rpath.RPath(Globals.local_connection, "./testfiles/robust/in")
fp = open("./testfiles/robust/in", "wb")
fp.write("hello there")
fp.close()
@@ -16,8 +15,8 @@ class TestRobustAction(unittest.TestCase):
rpin.setdata()
assert rpin.isreg() and rpin.getperms() % 01000 == 0604
- rpout = RPath(Globals.local_connection, "./testfiles/robust/out")
- Robust.copy_with_attribs_action(rpin, rpout).execute()
+ rpout = rpath.RPath(Globals.local_connection, "./testfiles/robust/out")
+ robust.copy_with_attribs_action(rpin, rpout).execute()
if not rpout == rpin:
print rpout, rpin
assert 0
@@ -28,17 +27,17 @@ class TestRobustAction(unittest.TestCase):
class TempFileTest(unittest.TestCase):
"""Test creation and management of tempfiles"""
- rp_base = RPath(Globals.local_connection,
- "./testfiles/robust/testfile_base")
+ rp_base = rpath.RPath(Globals.local_connection,
+ "./testfiles/robust/testfile_base")
def testBasic(self):
"""Make a temp file, write to it, and then delete it
Also test tempfile accounting and file name prefixing.
"""
- assert not TempFileManager._tempfiles
- tf = TempFileManager.new(self.rp_base)
- assert TempFileManager._tempfiles == [tf]
+ assert not TempFile._tempfiles
+ tf = TempFile.new(self.rp_base)
+ assert TempFile._tempfiles == [tf]
assert tf.dirsplit()[0] == "testfiles/robust", tf.dirsplit()[0]
assert not tf.lstat()
fp = tf.open("w")
@@ -48,37 +47,37 @@ class TempFileTest(unittest.TestCase):
assert fp.read() == "hello"
assert not fp.close()
tf.delete()
- assert not TempFileManager._tempfiles
+ assert not TempFile._tempfiles
def testRename(self):
"""Test renaming of tempfile"""
- tf = TempFileManager.new(self.rp_base)
- assert TempFileManager._tempfiles
+ tf = TempFile.new(self.rp_base)
+ assert TempFile._tempfiles
tf.touch()
- destination = RPath(Globals.local_connection,
- "./testfiles/robust/testfile_dest")
+ destination = rpath.RPath(Globals.local_connection,
+ "./testfiles/robust/testfile_dest")
tf.rename(destination)
- assert not TempFileManager._tempfiles
+ assert not TempFile._tempfiles
assert destination.lstat()
destination.delete()
class SaveStateTest(unittest.TestCase):
"""Test SaveState class"""
- data_dir = RPath(Globals.local_connection, "testfiles/robust")
+ data_dir = rpath.RPath(Globals.local_connection, "testfiles/robust")
def testSymlinking(self):
"""Test recording last file with symlink"""
- last_rorp = RORPath(('usr', 'local', 'bin', 'ls'))
+ last_rorp = rpath.RORPath(('usr', 'local', 'bin', 'ls'))
Globals.rbdir = self.data_dir
Time.setcurtime()
SetConnections.BackupInitConnections(Globals.local_connection,
Globals.local_connection)
- SaveState.init_filenames()
- SaveState.record_last_file_action(last_rorp).execute()
+ robust.SaveState.init_filenames()
+ robust.SaveState.record_last_file_action(last_rorp).execute()
- sym_rp = RPath(Globals.local_connection,
- "testfiles/robust/last-file-incremented.%s.data" %
- Time.curtimestr)
+ sym_rp = rpath.RPath(Globals.local_connection,
+ "testfiles/robust/last-file-incremented.%s.data" %
+ Time.curtimestr)
assert sym_rp.issym()
assert sym_rp.readlink() == "increments/usr/local/bin/ls"
sym_rp.delete()
diff --git a/rdiff-backup/testing/rorpitertest.py b/rdiff-backup/testing/rorpitertest.py
index e1e0926..ec786c2 100644
--- a/rdiff-backup/testing/rorpitertest.py
+++ b/rdiff-backup/testing/rorpitertest.py
@@ -1,10 +1,7 @@
-import unittest
+from __future__ import generators
+import unittest, time, pickle
from commontest import *
-from rdiff_backup.log import *
-from rdiff_backup.rpath import *
-from rdiff_backup.rorpiter import *
-from rdiff_backup import Globals
-
+from rdiff_backup import log, rpath, rorpiter, Globals, lazy
#Log.setverbosity(8)
@@ -17,10 +14,10 @@ class index:
class RORPIterTest(unittest.TestCase):
def setUp(self):
self.lc = Globals.local_connection
- self.inc0rp = RPath(self.lc, "testfiles/empty", ())
- self.inc1rp = RPath(self.lc, "testfiles/inc-reg-perms1", ())
- self.inc2rp = RPath(self.lc, "testfiles/inc-reg-perms2", ())
- self.output = RPath(self.lc, "testfiles/output", ())
+ self.inc0rp = rpath.RPath(self.lc, "testfiles/empty", ())
+ self.inc1rp = rpath.RPath(self.lc, "testfiles/inc-reg-perms1", ())
+ self.inc2rp = rpath.RPath(self.lc, "testfiles/inc-reg-perms2", ())
+ self.output = rpath.RPath(self.lc, "testfiles/output", ())
def testCollateIterators(self):
"""Test basic collating"""
@@ -31,44 +28,47 @@ class RORPIterTest(unittest.TestCase):
makeiter2 = lambda: iter(map(helper, [0,1,3]))
makeiter3 = lambda: iter(map(helper, [1,2]))
- outiter = RORPIter.CollateIterators(makeiter1(), makeiter2())
- assert Iter.equal(outiter,
- iter([(indicies[0], indicies[0]),
- (indicies[1], indicies[1]),
- (indicies[2], None),
- (indicies[3], indicies[3])]))
-
- assert Iter.equal(RORPIter.CollateIterators(makeiter1(),
- makeiter2(),
- makeiter3()),
- iter([(indicies[0], indicies[0], None),
- (indicies[1], indicies[1], indicies[1]),
- (indicies[2], None, indicies[2]),
- (indicies[3], indicies[3], None)]))
-
- assert Iter.equal(RORPIter.CollateIterators(makeiter1(), iter([])),
- iter(map(lambda i: (i, None),
- indicies)))
- assert Iter.equal(iter(map(lambda i: (i, None), indicies)),
- RORPIter.CollateIterators(makeiter1(), iter([])))
+ outiter = rorpiter.CollateIterators(makeiter1(), makeiter2())
+ assert lazy.Iter.equal(outiter,
+ iter([(indicies[0], indicies[0]),
+ (indicies[1], indicies[1]),
+ (indicies[2], None),
+ (indicies[3], indicies[3])]))
+
+ assert lazy.Iter.equal(rorpiter.CollateIterators(makeiter1(),
+ makeiter2(),
+ makeiter3()),
+ iter([(indicies[0], indicies[0], None),
+ (indicies[1], indicies[1], indicies[1]),
+ (indicies[2], None, indicies[2]),
+ (indicies[3], indicies[3], None)]))
+
+ assert lazy.Iter.equal(rorpiter.CollateIterators(makeiter1(),
+ iter([])),
+ iter(map(lambda i: (i, None),
+ indicies)))
+ assert lazy.Iter.equal(iter(map(lambda i: (i, None), indicies)),
+ rorpiter.CollateIterators(makeiter1(),
+ iter([])))
def testCombinedPatching(self):
"""Combined signature, patch, and diff operations"""
- if self.output.lstat(): self.output.delete()
+ if self.output.lstat():
+ Myrm(self.output.path)
+ self.output.setdata()
def turninto(final_rp):
- sigfile = RORPIter.ToFile(RORPIter.GetSignatureIter(self.output))
- diff_file = RORPIter.ToFile(
- RORPIter.GetDiffIter(RORPIter.FromFile(sigfile),
- RORPIter.IterateRPaths(final_rp)))
- RORPIter.PatchIter(self.output, RORPIter.FromFile(diff_file))
+ sigfile = rorpiter.ToFile(rorpiter.GetSignatureIter(self.output))
+ diff_file = rorpiter.ToFile(rorpiter.GetDiffIter(
+ rorpiter.FromFile(sigfile), rorpiter.IterateRPaths(final_rp)))
+ rorpiter.PatchIter(self.output, rorpiter.FromFile(diff_file))
turninto(self.inc1rp)
- RPath.copy_attribs(self.inc1rp, self.output) # Update time
+ rpath.copy_attribs(self.inc1rp, self.output) # Update time
assert self.compare_no_times(self.inc1rp, self.output)
turninto(self.inc2rp)
- RPath.copy_attribs(self.inc2rp, self.output)
+ rpath.copy_attribs(self.inc2rp, self.output)
assert self.compare_no_times(self.inc2rp, self.output)
def compare_no_times(self, src_rp, dest_rp):
@@ -83,8 +83,8 @@ class RORPIterTest(unittest.TestCase):
class IndexedTupleTest(unittest.TestCase):
def testTuple(self):
"""Test indexed tuple"""
- i = IndexedTuple((1,2,3), ("a", "b"))
- i2 = IndexedTuple((), ("hello", "there", "how are you"))
+ i = rorpiter.IndexedTuple((1,2,3), ("a", "b"))
+ i2 = rorpiter.IndexedTuple((), ("hello", "there", "how are you"))
assert i[0] == "a"
assert i[1] == "b"
@@ -93,10 +93,186 @@ class IndexedTupleTest(unittest.TestCase):
assert i2 < i, i2 < i
def testTupleAssignment(self):
- a, b, c = IndexedTuple((), (1, 2, 3))
+ a, b, c = rorpiter.IndexedTuple((), (1, 2, 3))
assert a == 1
assert b == 2
assert c == 3
+
+class DirHandlerTest(unittest.TestCase):
+ made_test_dir = 0 # Set to 1 once we have made the test dir
+ def make_test_dir(self):
+ """Make the test directory"""
+ self.rootrp = RPath(Globals.local_connection, "testfiles/output")
+ self.rootrp.delete()
+ self.rootrp.mkdir()
+
+ self.a = self.rootrp.append("a")
+ self.b = self.rootrp.append("b")
+ self.c = self.rootrp.append("c")
+ self.a.mkdir()
+ self.b.mkdir()
+ self.b.chmod(0700)
+ self.c.mkdir()
+ self.c.chmod(0500) # No write permissions to c
+
+ self.rootmtime = self.rootrp.getmtime()
+ self.amtime = self.a.getmtime()
+ self.bmtime = self.b.getmtime()
+ self.cmtime = self.c.getmtime()
+
+ self.made_test_dir = 1
+
+ def test_times_and_writes(self):
+ """Test writing without disrupting times, and to unwriteable dir"""
+ return
+ self.make_test_dir()
+ time.sleep(1) # make sure the mtimes would get updated otherwise
+ DH = DirHandler(self.rootrp)
+
+ new_a_rp = self.a.append("foo")
+ DH(new_a_rp)
+ new_a_rp.touch()
+
+ DH(self.b)
+ self.b.chmod(0751)
+ new_b_rp = self.b.append("aoenuth")
+ DH(new_b_rp)
+ new_b_rp.touch()
+
+ new_root_rp = self.rootrp.append("bb")
+ DH(new_root_rp)
+ new_root_rp.touch()
+
+ new_c_rp = self.c.append("bar")
+ DH(new_c_rp)
+ new_c_rp.touch()
+ DH.Finish()
+
+ assert new_a_rp.lstat() and new_b_rp.lstat() and new_c_rp.lstat()
+ self.a.setdata()
+ self.b.setdata()
+ self.c.setdata()
+ assert self.a.getmtime() == self.amtime
+ assert self.c.getmtime() == self.cmtime
+ assert self.rootrp.getmtime() == self.rootmtime
+ assert self.b.getperms() == 0751
+ assert self.c.getperms() == 0500
+
+
+class FillTest(unittest.TestCase):
+ def test_fill_in(self):
+ """Test fill_in_iter"""
+ rootrp = RPath(Globals.local_connection, "testfiles/output")
+ def get_rpiter():
+ for int_index in [(1,2), (1,3), (1,4),
+ (2,), (2,1),
+ (3,4,5), (3,6)]:
+ index = tuple(map(lambda i: str(i), int_index))
+ yield rootrp.new_index(index)
+
+ filled_in = rorpiter.FillInIter(get_rpiter(), rootrp)
+ rp_list = list(filled_in)
+ index_list = map(lambda rp: tuple(map(int, rp.index)), rp_list)
+ assert index_list == [(), (1,), (1,2), (1,3), (1,4),
+ (2,), (2,1),
+ (3,), (3,4), (3,4,5), (3,6)], index_list
+
+
+class ITRBadder(rorpiter.ITRBranch):
+ def start_process(self, index):
+ self.total = 0
+
+ def end_process(self):
+ if self.base_index:
+ summand = self.base_index[-1]
+ #print "Adding ", summand
+ self.total += summand
+
+ def branch_process(self, subinstance):
+ #print "Adding subinstance ", subinstance.total
+ self.total += subinstance.total
+
+class ITRBadder2(rorpiter.ITRBranch):
+ def start_process(self, index):
+ self.total = 0
+
+ def end_process(self):
+ #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
+
+
+class TreeReducerTest(unittest.TestCase):
+ def setUp(self):
+ self.i1 = [(), (1,), (2,), (3,)]
+ self.i2 = [(0,), (0,1), (0,1,0), (0,1,1), (0,2), (0,2,1), (0,3)]
+
+ self.i1a = [(), (1,)]
+ self.i1b = [(2,), (3,)]
+ self.i2a = [(0,), (0,1), (0,1,0)]
+ self.i2b = [(0,1,1), (0,2)]
+ self.i2c = [(0,2,1), (0,3)]
+
+ def testTreeReducer(self):
+ """testing IterTreeReducer"""
+ itm = rorpiter.IterTreeReducer(ITRBadder, [])
+ for index in self.i1:
+ val = itm(index)
+ assert val, (val, index)
+ itm.Finish()
+ assert itm.root_branch.total == 6, itm.root_branch.total
+
+ itm2 = rorpiter.IterTreeReducer(ITRBadder2, [])
+ for index in self.i2:
+ val = itm2(index)
+ if index == (): assert not val
+ else: assert val
+ itm2.Finish()
+ assert itm2.root_branch.total == 12, itm2.root_branch.total
+
+ def testTreeReducerState(self):
+ """Test saving and recreation of an IterTreeReducer"""
+ itm1a = rorpiter.IterTreeReducer(ITRBadder, [])
+ for index in self.i1a:
+ val = itm1a(index)
+ assert val, index
+ itm1b = pickle.loads(pickle.dumps(itm1a))
+ for index in self.i1b:
+ val = itm1b(index)
+ assert val, index
+ itm1b.Finish()
+ assert itm1b.root_branch.total == 6, itm1b.root_branch.total
+
+ itm2a = rorpiter.IterTreeReducer(ITRBadder2, [])
+ for index in self.i2a:
+ val = itm2a(index)
+ if index == (): assert not val
+ else: assert val
+ itm2b = pickle.loads(pickle.dumps(itm2a))
+ for index in self.i2b:
+ val = itm2b(index)
+ if index == (): assert not val
+ else: assert val
+ itm2c = pickle.loads(pickle.dumps(itm2b))
+ for index in self.i2c:
+ val = itm2c(index)
+ if index == (): assert not val
+ else: assert val
+ itm2c.Finish()
+ 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 fe19d03..3b2939f 100644
--- a/rdiff-backup/testing/rpathtest.py
+++ b/rdiff-backup/testing/rpathtest.py
@@ -1,7 +1,7 @@
import os, cPickle, sys, unittest
from commontest import *
from rdiff_backup.rpath import *
-
+from rdiff_backup import rpath
class RPathTest(unittest.TestCase):
lc = Globals.local_connection
@@ -313,18 +313,18 @@ class FileCopying(RPathTest):
def testComp(self):
"""Test comparisons involving regular files"""
- assert RPath.cmp(self.hl1, self.hl2)
- assert not RPath.cmp(self.rf, self.hl1)
- assert not RPath.cmp(self.dir, self.rf)
+ assert rpath.cmp(self.hl1, self.hl2)
+ assert not rpath.cmp(self.rf, self.hl1)
+ assert not rpath.cmp(self.dir, self.rf)
def testCompMisc(self):
"""Test miscellaneous comparisons"""
- assert RPath.cmp(self.dir, RPath(self.lc, self.mainprefix, ()))
+ assert rpath.cmp(self.dir, RPath(self.lc, self.mainprefix, ()))
self.dest.symlink("regular_file")
- assert RPath.cmp(self.sl, self.dest)
+ assert rpath.cmp(self.sl, self.dest)
self.dest.delete()
- assert not RPath.cmp(self.sl, self.fifo)
- assert not RPath.cmp(self.dir, self.sl)
+ assert not rpath.cmp(self.sl, self.fifo)
+ assert not rpath.cmp(self.dir, self.sl)
def testDirSizeComp(self):
"""Make sure directories can be equal,
@@ -338,10 +338,10 @@ class FileCopying(RPathTest):
def testCopy(self):
"""Test copy of various files"""
for rp in [self.sl, self.rf, self.fifo, self.dir]:
- RPath.copy(rp, self.dest)
+ rpath.copy(rp, self.dest)
assert self.dest.lstat(), "%s doesn't exist" % self.dest.path
- assert RPath.cmp(rp, self.dest)
- assert RPath.cmp(self.dest, rp)
+ assert rpath.cmp(rp, self.dest)
+ assert rpath.cmp(self.dest, rp)
self.dest.delete()
@@ -361,8 +361,8 @@ class FileAttributes(FileCopying):
"""Test attribute comparison success"""
testpairs = [(self.hl1, self.hl2)]
for a, b in testpairs:
- assert RPath.cmp_attribs(a, b), "Err with %s %s" % (a.path, b.path)
- assert RPath.cmp_attribs(b, a), "Err with %s %s" % (b.path, a.path)
+ assert rpath.cmp_attribs(a, b), "Err with %s %s" % (a.path, b.path)
+ assert rpath.cmp_attribs(b, a), "Err with %s %s" % (b.path, a.path)
def testCompFail(self):
"""Test attribute comparison failures"""
@@ -370,16 +370,16 @@ class FileAttributes(FileCopying):
(self.exec1, self.exec2),
(self.rf, self.hl1)]
for a, b in testpairs:
- assert not RPath.cmp_attribs(a, b), \
+ assert not rpath.cmp_attribs(a, b), \
"Err with %s %s" % (a.path, b.path)
- assert not RPath.cmp_attribs(b, a), \
+ assert not rpath.cmp_attribs(b, a), \
"Err with %s %s" % (b.path, a.path)
def testCompRaise(self):
"""Should raise exception when file missing"""
- self.assertRaises(RPathException, RPath.cmp_attribs,
+ self.assertRaises(RPathException, rpath.cmp_attribs,
self.nothing, self.hl1)
- self.assertRaises(RPathException, RPath.cmp_attribs,
+ self.assertRaises(RPathException, rpath.cmp_attribs,
self.noperms, self.nothing)
def testCopyAttribs(self):
@@ -389,8 +389,8 @@ class FileAttributes(FileCopying):
for rp in [self.noperms, self.nowrite, self.rf, self.exec1,
self.exec2, self.hl1, self.dir]:
t.touch()
- RPath.copy_attribs(rp, t)
- assert RPath.cmp_attribs(t, rp), \
+ rpath.copy_attribs(rp, t)
+ assert rpath.cmp_attribs(t, rp), \
"Attributes for file %s not copied successfully" % rp.path
t.delete()
@@ -400,16 +400,16 @@ class FileAttributes(FileCopying):
if out.lstat(): out.delete()
for rp in [self.noperms, self.nowrite, self.rf, self.exec1,
self.exec2, self.hl1, self.dir, self.sym]:
- RPath.copy_with_attribs(rp, out)
- assert RPath.cmp(rp, out)
- assert RPath.cmp_attribs(rp, out)
+ rpath.copy_with_attribs(rp, out)
+ assert rpath.cmp(rp, out)
+ assert rpath.cmp_attribs(rp, out)
out.delete()
def testCopyRaise(self):
"""Should raise exception for non-existent files"""
- self.assertRaises(RPathException, RPath.copy_attribs,
+ self.assertRaises(RPathException, rpath.copy_attribs,
self.hl1, self.nothing)
- self.assertRaises(RPathException, RPath.copy_attribs,
+ self.assertRaises(RPathException, rpath.copy_attribs,
self.nothing, self.nowrite)
class CheckPath(unittest.TestCase):
diff --git a/rdiff-backup/testing/selectiontest.py b/rdiff-backup/testing/selectiontest.py
index 19c3ff8..8fa970d 100644
--- a/rdiff-backup/testing/selectiontest.py
+++ b/rdiff-backup/testing/selectiontest.py
@@ -1,18 +1,17 @@
from __future__ import generators
-import re, StringIO, unittest
+import re, StringIO, unittest, types
from commontest import *
from rdiff_backup.selection import *
-from rdiff_backup.destructive_stepping import *
-from rdiff_backup import Globals
+from rdiff_backup import Globals, rpath, lazy
class MatchingTest(unittest.TestCase):
"""Test matching of file names against various selection functions"""
- def makedsrp(self, path): return DSRPath(1, Globals.local_connection, path)
+ def makerp(self, path): return rpath.RPath(Globals.local_connection, path)
def makeext(self, path): return self.root.new_index(tuple(path.split("/")))
def setUp(self):
- self.root = DSRPath(1, Globals.local_connection, "testfiles/select")
+ self.root = rpath.RPath(Globals.local_connection, "testfiles/select")
self.Select = Select(self.root)
def testRegexp(self):
@@ -23,9 +22,9 @@ class MatchingTest(unittest.TestCase):
assert sf1(self.root.append("1.doc")) == None
sf2 = self.Select.regexp_get_sf("hello", 0)
- assert sf2(self.makedsrp("hello")) == 0
- assert sf2(self.makedsrp("foohello_there")) == 0
- assert sf2(self.makedsrp("foo")) == None
+ assert sf2(self.makerp("hello")) == 0
+ assert sf2(self.makerp("foohello_there")) == 0
+ assert sf2(self.makerp("foo")) == None
def testTupleInclude(self):
"""Test include selection function made from a regular filename"""
@@ -242,7 +241,7 @@ testfiles/select/1/1
def testRoot(self):
"""testRoot - / may be a counterexample to several of these.."""
- root = DSRPath(1, Globals.local_connection, "/")
+ root = rpath.RPath(Globals.local_connection, "/")
select = Select(root)
assert select.glob_get_sf("/", 1)(root) == 1
@@ -267,7 +266,7 @@ testfiles/select/1/1
def testOtherFilesystems(self):
"""Test to see if --exclude-other-filesystems works correctly"""
- root = DSRPath(1, Globals.local_connection, "/")
+ root = rpath.RPath(Globals.local_connection, "/")
select = Select(root)
sf = select.other_filesystems_get_sf(0)
assert sf(root) is None
@@ -284,13 +283,13 @@ class ParseArgsTest(unittest.TestCase):
def ParseTest(self, tuplelist, indicies, filelists = []):
"""No error if running select on tuple goes over indicies"""
if not self.root:
- self.root = DSRPath(1, Globals.local_connection,
- "testfiles/select")
+ self.root = RPath(Globals.local_connection, "testfiles/select")
self.Select = Select(self.root)
self.Select.ParseArgs(tuplelist, self.remake_filelists(filelists))
self.Select.set_iter()
- assert Iter.equal(Iter.map(lambda dsrp: dsrp.index, self.Select),
- iter(indicies), verbose = 1)
+ assert lazy.Iter.equal(lazy.Iter.map(lambda dsrp: dsrp.index,
+ self.Select),
+ iter(indicies), verbose = 1)
def remake_filelists(self, filelist):
"""Turn strings in filelist into fileobjs"""
@@ -408,12 +407,11 @@ testfiles/select**/2
def testAlternateRoot(self):
"""Test select with different root"""
- self.root = DSRPath(1, Globals.local_connection,
- "testfiles/select/1")
+ self.root = rpath.RPath(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.root = rpath.RPath(Globals.local_connection, "/")
self.ParseTest([("--exclude", "/home/*"),
("--include", "/home"),
("--exclude", "/")],
@@ -421,12 +419,13 @@ testfiles/select**/2
def testParseStartingFrom(self):
"""Test parse, this time starting from inside"""
- self.root = DSRPath(1, Globals.local_connection, "testfiles/select")
+ self.root = rpath.RPath(Globals.local_connection, "testfiles/select")
self.Select = Select(self.root)
self.Select.ParseArgs([("--include", "testfiles/select/1/1"),
("--exclude", "**")], [])
self.Select.set_iter(('1', '1'))
- assert Iter.equal(Iter.map(lambda dsrp: dsrp.index, self.Select),
+ assert lazy.Iter.equal(lazy.Iter.map(lambda dsrp: dsrp.index,
+ self.Select),
iter([("1", '1', '1'),
('1', '1', '2'),
('1', '1', '3')]),
diff --git a/rdiff-backup/testing/statisticstest.py b/rdiff-backup/testing/statisticstest.py
index f7c858a..7e8f02c 100644
--- a/rdiff-backup/testing/statisticstest.py
+++ b/rdiff-backup/testing/statisticstest.py
@@ -1,6 +1,6 @@
import unittest
from commontest import *
-from rdiff_backup.statistics import *
+from rdiff_backup import statistics, rpath
class StatsObjTest(unittest.TestCase):
"""Test StatsObj class"""
@@ -24,17 +24,17 @@ class StatsObjTest(unittest.TestCase):
def test_get_stats(self):
"""Test reading and writing stat objects"""
- s = StatsObj()
+ s = statistics.StatsObj()
assert s.get_stat('SourceFiles') is None
self.set_obj(s)
assert s.get_stat('SourceFiles') == 1
- s1 = StatsITRB()
+ s1 = statistics.ITRB()
assert s1.get_stat('SourceFiles') == 0
def test_get_stats_string(self):
"""Test conversion of stat object into string"""
- s = StatsObj()
+ s = statistics.StatsObj()
stats_string = s.get_stats_string()
assert stats_string == "", stats_string
@@ -62,7 +62,7 @@ TotalDestinationSizeChange 7 (7 bytes)
def test_line_string(self):
"""Test conversion to a single line"""
- s = StatsObj()
+ s = statistics.StatsObj()
self.set_obj(s)
statline = s.get_stats_line(("sample", "index", "w", "new\nline"))
assert statline == "sample/index/w/new\\nline 1 2 13 14 " \
@@ -77,7 +77,7 @@ TotalDestinationSizeChange 7 (7 bytes)
def test_byte_summary(self):
"""Test conversion of bytes to strings like 7.23MB"""
- s = StatsObj()
+ s = statistics.StatsObj()
f = s.get_byte_summary_string
assert f(1) == "1 byte"
assert f(234.34) == "234 bytes"
@@ -89,36 +89,36 @@ TotalDestinationSizeChange 7 (7 bytes)
def test_init_stats(self):
"""Test setting stat object from string"""
- s = StatsObj()
+ s = statistics.StatsObj()
s.set_stats_from_string("NewFiles 3 hello there")
for attr in s.stat_attrs:
if attr == 'NewFiles': assert s.get_stat(attr) == 3
else: assert s.get_stat(attr) is None, (attr, s.__dict__[attr])
- s1 = StatsObj()
+ s1 = statistics.StatsObj()
self.set_obj(s1)
assert not s1.stats_equal(s)
- s2 = StatsObj()
+ s2 = statistics.StatsObj()
s2.set_stats_from_string(s1.get_stats_string())
assert s1.stats_equal(s2)
def test_write_rp(self):
"""Test reading and writing of statistics object"""
- rp = RPath(Globals.local_connection, "testfiles/statstest")
+ rp = rpath.RPath(Globals.local_connection, "testfiles/statstest")
if rp.lstat(): rp.delete()
- s = StatsObj()
+ s = statistics.StatsObj()
self.set_obj(s)
s.write_stats_to_rp(rp)
- s2 = StatsObj()
+ s2 = statistics.StatsObj()
assert not s2.stats_equal(s)
s2.read_stats_from_rp(rp)
assert s2.stats_equal(s)
def testAverage(self):
"""Test making an average statsobj"""
- s1 = StatsObj()
+ s1 = statistics.StatsObj()
s1.StartTime = 5
s1.EndTime = 10
s1.ElapsedTime = 5
@@ -126,7 +126,7 @@ TotalDestinationSizeChange 7 (7 bytes)
s1.SourceFiles = 100
s1.NewFileSize = 4
- s2 = StatsObj()
+ s2 = statistics.StatsObj()
s2.StartTime = 25
s2.EndTime = 35
s2.ElapsedTime = 10
@@ -134,7 +134,7 @@ TotalDestinationSizeChange 7 (7 bytes)
s2.SourceFiles = 50
s2.DeletedFiles = 0
- s3 = StatsObj().set_to_average([s1, s2])
+ s3 = statistics.StatsObj().set_to_average([s1, s2])
assert s3.StartTime is s3.EndTime is None
assert s3.ElapsedTime == 7.5
assert s3.DeletedFiles is s3.NewFileSize is None, (s3.DeletedFiles,
diff --git a/rdiff-backup/testing/timetest.py b/rdiff-backup/testing/timetest.py
index 479a07a..97286a8 100644
--- a/rdiff-backup/testing/timetest.py
+++ b/rdiff-backup/testing/timetest.py
@@ -1,4 +1,4 @@
-import unittest, time
+import unittest, time, types
from commontest import *
from rdiff_backup import Globals, Time