コード例 #1
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
 def test_rsync_default_reporting(self):
     source = self.source
     source.ensure("hello")
     cap = py.io.StdCapture()
     try:
         rsync = RSync(source)
         rsync.add_target(gw, self.dest1)
         rsync.send()
     finally:
         out, err = cap.reset()
     assert out.find("hello") != -1
コード例 #2
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
 def test_rsync_non_verbose(self):
     source = self.source
     source.ensure("hello")
     cap = py.io.StdCapture()
     try:
         rsync = RSync(source, verbose=False)
         rsync.add_target(gw, self.dest1)
         rsync.send()
     finally:
         out, err = cap.reset()
     assert not out
     assert not err
コード例 #3
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
 def test_symlink_rsync(self):
     if py.std.sys.platform == 'win32':
         py.test.skip("symlinks are unsupported on Windows.")
     source = self.source
     dest = self.dest1
     self.source.ensure("existant")
     source.join("rellink").mksymlinkto(source.join("existant"), absolute=0)
     source.join('abslink').mksymlinkto(source.join("existant"))
     
     rsync = RSync(source)
     rsync.add_target(gw, dest)
     rsync.send()
     
     assert dest.join('rellink').readlink() == dest.join("existant")
     assert dest.join('abslink').readlink() == dest.join("existant")
コード例 #4
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
    def test_callback(self):
        dest = self.dest1
        source = self.source
        source.ensure("existant").write("a" * 100)
        source.ensure("existant2").write("a" * 10)
        total = {}
        def callback(cmd, lgt, channel):
            total[(cmd, lgt)] = True

        rsync = RSync(source, callback=callback)
        #rsync = RSync()
        rsync.add_target(gw, dest)
        rsync.send()

        assert total == {("list", 110):True, ("ack", 100):True, ("ack", 10):True}
コード例 #5
0
 def test_rsync_default_reporting(self):
     source = self.source
     source.ensure("hello")
     cap = py.io.StdCapture()
     try:
         rsync = RSync(source)
         rsync.add_target(gw, self.dest1)
         rsync.send()
     finally:
         out, err = cap.reset()
     assert out.find("hello") != -1
コード例 #6
0
 def test_rsync_non_verbose(self):
     source = self.source
     source.ensure("hello")
     cap = py.io.StdCapture()
     try:
         rsync = RSync(source, verbose=False)
         rsync.add_target(gw, self.dest1)
         rsync.send()
     finally:
         out, err = cap.reset()
     assert not out
     assert not err
コード例 #7
0
    def test_symlink_rsync(self):
        if py.std.sys.platform == 'win32':
            py.test.skip("symlinks are unsupported on Windows.")
        source = self.source
        dest = self.dest1
        self.source.ensure("existant")
        source.join("rellink").mksymlinkto(source.join("existant"), absolute=0)
        source.join('abslink').mksymlinkto(source.join("existant"))

        rsync = RSync(source)
        rsync.add_target(gw, dest)
        rsync.send()

        assert dest.join('rellink').readlink() == dest.join("existant")
        assert dest.join('abslink').readlink() == dest.join("existant")
コード例 #8
0
    def test_callback(self):
        dest = self.dest1
        source = self.source
        source.ensure("existant").write("a" * 100)
        source.ensure("existant2").write("a" * 10)
        total = {}

        def callback(cmd, lgt, channel):
            total[(cmd, lgt)] = True

        rsync = RSync(source, callback=callback)
        #rsync = RSync()
        rsync.add_target(gw, dest)
        rsync.send()

        assert total == {
            ("list", 110): True,
            ("ack", 100): True,
            ("ack", 10): True
        }
コード例 #9
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
 def test_dirsync_twice(self):
     source = self.source
     source.ensure("hello")
     rsync = RSync(source)
     rsync.add_target(gw, self.dest1)
     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
コード例 #10
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
    def test_dirsync(self):
        dest = self.dest1
        dest2 = self.dest2
        source = self.source

        for s in ('content1', 'content2-a-bit-longer'): 
            source.ensure('subdir', 'file1').write(s) 
            rsync = RSync(self.source)
            rsync.add_target(gw, dest)
            rsync.add_target(gw2, dest2)
            rsync.send()
            assert dest.join('subdir').check(dir=1)
            assert dest.join('subdir', 'file1').check(file=1)
            assert dest.join('subdir', 'file1').read() == s 
            assert dest2.join('subdir').check(dir=1)
            assert dest2.join('subdir', 'file1').check(file=1)
            assert dest2.join('subdir', 'file1').read() == s 
        
        source.join('subdir').remove('file1')
        rsync = RSync(source)
        rsync.add_target(gw2, dest2)
        rsync.add_target(gw, dest)
        rsync.send()
        assert dest.join('subdir', 'file1').check(file=1)
        assert dest2.join('subdir', 'file1').check(file=1)
        rsync = RSync(source)
        rsync.add_target(gw, dest, delete=True)
        rsync.add_target(gw2, dest2)
        rsync.send()
        assert not dest.join('subdir', 'file1').check() 
        assert dest2.join('subdir', 'file1').check() 
コード例 #11
0
ファイル: test_rsync.py プロジェクト: TheDunn/flex-pypy
 def test_notargets(self):
     rsync = RSync(self.source)
     py.test.raises(IOError, "rsync.send()")
     assert rsync.send(raises=False) is None
コード例 #12
0
 def test_dirsync_twice(self):
     source = self.source
     source.ensure("hello")
     rsync = RSync(source)
     rsync.add_target(gw, self.dest1)
     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
コード例 #13
0
    def test_dirsync(self):
        dest = self.dest1
        dest2 = self.dest2
        source = self.source

        for s in ('content1', 'content2', 'content2-a-bit-longer'):
            source.ensure('subdir', 'file1').write(s)
            rsync = RSync(self.source)
            rsync.add_target(gw, dest)
            rsync.add_target(gw2, dest2)
            rsync.send()
            assert dest.join('subdir').check(dir=1)
            assert dest.join('subdir', 'file1').check(file=1)
            assert dest.join('subdir', 'file1').read() == s
            assert dest2.join('subdir').check(dir=1)
            assert dest2.join('subdir', 'file1').check(file=1)
            assert dest2.join('subdir', 'file1').read() == s
            for x in dest, dest2:
                fn = x.join("subdir", "file1")
                fn.setmtime(0)

        source.join('subdir').remove('file1')
        rsync = RSync(source)
        rsync.add_target(gw2, dest2)
        rsync.add_target(gw, dest)
        rsync.send()
        assert dest.join('subdir', 'file1').check(file=1)
        assert dest2.join('subdir', 'file1').check(file=1)
        rsync = RSync(source)
        rsync.add_target(gw, dest, delete=True)
        rsync.add_target(gw2, dest2)
        rsync.send()
        assert not dest.join('subdir', 'file1').check()
        assert dest2.join('subdir', 'file1').check()
コード例 #14
0
 def test_notargets(self):
     rsync = RSync(self.source)
     py.test.raises(IOError, "rsync.send()")
     assert rsync.send(raises=False) is None