Example #1
0
    def testsnapshot(self):
        """Test making of a snapshot"""
        Globals.compression = None
        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 snap_rp2.equal_verbose(rf, check_index=0)
        assert rpath.cmp(snap_rp2, rf)
        snap_rp2.delete()
Example #2
0
    def testGzipsnapshot(self):
        """Test making a compressed snapshot"""
        Globals.compression = 1
        rp = increment.Increment(rf, sym, target)
        self.check_time(rp)
        assert rp.equal_verbose(sym, check_index=0, compare_size=0)
        assert rpath.cmp(rp, sym)
        rp.delete()

        rp = increment.Increment(sym, rf, target)
        self.check_time(rp)
        assert rp.equal_verbose(rf, check_index=0, compare_size=0)
        assert rpath.cmpfileobj(rp.open("rb", 1), rf.open("rb"))
        assert rp.isinccompressed()
        rp.delete()
Example #3
0
    def testGzipsnapshot(self):
        """Test making a compressed snapshot"""
        Globals.compression = 1
        rp = increment.Increment(rf, sym, target)
        self.check_time(rp)
        self.assertTrue(rp._equal_verbose(sym, check_index=0, compare_size=0))
        self.assertTrue(rpath.cmp(rp, sym))
        rp.delete()

        rp = increment.Increment(sym, rf, target)
        self.check_time(rp)
        self.assertTrue(rp._equal_verbose(rf, check_index=0, compare_size=0))
        with rp.open("rb", 1) as rp_fd, rf.open("rb") as rf_fd:
            self.assertTrue(rpath._cmp_file_obj(rp_fd, rf_fd))
        self.assertTrue(rp.isinccompressed())
        rp.delete()
Example #4
0
 def testGzipDiff(self):
     """Test making gzipped diffs"""
     Globals.compression = 1
     rp = increment.Increment(rf, rf2, target)
     self.check_time(rp)
     assert rp.equal_verbose(rf2, check_index=0, compare_size=0)
     Rdiff.patch_local(rf, rp, out2, delta_compressed=1)
     assert rpath.cmp(rf2, out2)
     rp.delete()
     out2.delete()
Example #5
0
 def testDiff(self):
     """Test making diffs"""
     Globals.compression = None
     rp = increment.Increment(rf, rf2, target)
     self.check_time(rp)
     self.assertTrue(rp._equal_verbose(rf2, check_index=0, compare_size=0))
     Rdiff.patch_local(rf, rp, out2)
     self.assertTrue(rpath.cmp(rf2, out2))
     rp.delete()
     out2.delete()
Example #6
0
 def start_process_directory(self, index, diff_rorp):
     """Start processing directory"""
     self.base_rp, inc_prefix = longname.get_mirror_inc_rps(
         self.CCPP.get_rorps(index), self.basis_root_rp, self.inc_root_rp)
     self.base_rp.setdata()
     assert diff_rorp.isdir() or self.base_rp.isdir(), (
         "Either diff '{ipath!r}' or base '{bpath!r}' "
         "must be a directory".format(ipath=diff_rorp, bpath=self.base_rp))
     if diff_rorp.isdir():
         inc = increment.Increment(diff_rorp, self.base_rp, inc_prefix)
         if inc and inc.isreg():
             inc.fsync_with_dir()  # must write inc before rp changed
         self.base_rp.setdata()  # in case written by increment above
         self._prepare_dir(diff_rorp, self.base_rp)
     elif self._set_dir_replacement(diff_rorp, self.base_rp):
         inc = increment.Increment(self.dir_replacement, self.base_rp,
                                   inc_prefix)
         if inc:
             self.CCPP.set_inc(index, inc)
             self.CCPP.flag_success(index)
Example #7
0
 def testdir(self):
     """Test increment on dir"""
     rp = increment.Increment(sym, dir, target)
     self.check_time(rp)
     assert rp.lstat()
     assert target.isdir()
     assert dir.equal_verbose(rp,
                              check_index=0,
                              compare_size=0,
                              compare_type=0)
     assert rp.isreg()
     rp.delete()
     target.delete()
Example #8
0
    def testreg(self):
        """Test increment of regular files"""
        Globals.compression = None
        target.setdata()
        if target.lstat(): target.delete()
        rpd = rpath.RPath(lc, t_diff)
        if rpd.lstat(): rpd.delete()

        diffrp = increment.Increment(rf, exec1, target)
        assert diffrp.isreg(), diffrp
        assert diffrp.equal_verbose(exec1, check_index=0, compare_size=0)
        self.check_time(diffrp)
        assert diffrp.getinctype() == 'diff', diffrp.getinctype()
        diffrp.delete()
Example #9
0
    def testGzipRegexp(self):
        """Here a .gz file shouldn't be compressed"""
        Globals.compression = 1
        rpath.copy(rf, out_gz)
        assert out_gz.lstat()

        rp = increment.Increment(rf, out_gz, target)
        self.check_time(rp)
        assert rp.equal_verbose(out_gz, check_index=0, compare_size=0)
        Rdiff.patch_local(rf, rp, out2)
        assert rpath.cmp(out_gz, out2)
        rp.delete()
        out2.delete()
        out_gz.delete()
Example #10
0
 def testmissing(self):
     """Test creation of missing files"""
     missing_rp = increment.Increment(rf, nothing, target)
     self.check_time(missing_rp)
     assert missing_rp.getinctype() == 'missing'
     missing_rp.delete()