[svn r38174] Flag instead of new method and a test.
--HG-- branch : trunk
This commit is contained in:
parent
27cf3997e3
commit
e3dce2c288
|
@ -93,19 +93,16 @@ class RSync(object):
|
|||
if self._verbose:
|
||||
print '%s <= %s' % (gateway.remoteaddress, modified_rel_path)
|
||||
|
||||
def send_if_targets(self):
|
||||
""" Sends only if there are targets, otherwise returns
|
||||
def send(self, raises=True):
|
||||
""" Sends a sourcedir to all added targets. Flag indicates
|
||||
whether to raise an error or return in case of lack of
|
||||
targets
|
||||
"""
|
||||
if not self._channels:
|
||||
if raises:
|
||||
raise IOError("no targets available, maybe you "
|
||||
"are trying call send() twice?")
|
||||
return
|
||||
self.send()
|
||||
|
||||
def send(self):
|
||||
""" Sends a sourcedir to all added targets.
|
||||
"""
|
||||
if not self._channels:
|
||||
raise IOError("no targets available, maybe you "
|
||||
"are trying call send() twice?")
|
||||
# normalize a trailing '/' away
|
||||
self._sourcedir = os.path.dirname(os.path.join(self._sourcedir, 'x'))
|
||||
# send directory structure and file timestamps/sizes
|
||||
|
|
|
@ -23,6 +23,7 @@ class TestRSync(DirSetup):
|
|||
def test_notargets(self):
|
||||
rsync = RSync(self.source)
|
||||
py.test.raises(IOError, "rsync.send()")
|
||||
assert rsync.send(raises=False) is None
|
||||
|
||||
def test_dirsync(self):
|
||||
dest = self.dest1
|
||||
|
@ -64,10 +65,12 @@ class TestRSync(DirSetup):
|
|||
rsync.send()
|
||||
assert self.dest1.join('hello').check()
|
||||
py.test.raises(IOError, "rsync.send()")
|
||||
assert rsync.send(raises=False) is None
|
||||
rsync.add_target(gw, self.dest2)
|
||||
rsync.send()
|
||||
assert self.dest2.join('hello').check()
|
||||
py.test.raises(IOError, "rsync.send()")
|
||||
assert rsync.send(raises=False) is None
|
||||
|
||||
def test_rsync_default_reporting(self):
|
||||
source = self.source
|
||||
|
|
Loading…
Reference in New Issue