コード例 #1
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def _do_test(self, name):
        src_dir = self._get_source_directory(name)

        obj = Pydumpfs(**self._get_pydumpfs_options())
        backup_dir = obj.do(self.dest_dir, src_dir)

        self._compare_dir_recursively(backup_dir, src_dir)
コード例 #2
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
 def test_no_dest_dir(self):
     dest_dir = join(self.dest_dir, "test_no_dest_dir")
     obj = Pydumpfs(**self._get_pydumpfs_options())
     try:
         backup_dir \
                 = obj.do(dest_dir, self._get_source_directory("new_file"))
     except PydumpfsError:
         pass
     else:
         self.assert_(False, "Can backup to directory which doesn't exist.")
コード例 #3
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_remove_file(self):
        name = "remove_file"
        src_dir = self._get_source_directory(name)
        file_path = join(src_dir, "foo")

        self._make_sample_file(file_path)

        obj = Pydumpfs()
        obj.do(self.dest_dir, src_dir)

        remove(file_path)

        self._do_test(name)
コード例 #4
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_hard_link(self):
        name = "hard_link"
        src_dir = self._get_source_directory(name)

        obj = Pydumpfs(**self._get_pydumpfs_options())
        backup_dir1 = obj.do(self.dest_dir, src_dir)
        backup_dir2 = obj.do(self.dest_dir, src_dir)

        foo_src_path = join(src_dir, "foo")
        path1 = backup_dir1 + foo_src_path
        path2 = backup_dir2 + foo_src_path
        self.assert_(samefile(path1, path2),
            "%(path1)r's i-node and %(path2)r's one are not same."
                % dict(path1=path1, path2=path2))
コード例 #5
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_new_file(self):
        name = "new_file"
        src_dir = self._get_source_directory(name)
        file_path = join(src_dir, "foo")
        if isfile(file_path):
            remove(file_path)
        elif isdir(file_path):
            rmtree(file_path)

        obj = Pydumpfs()
        obj.do(self.dest_dir, src_dir)

        self._make_sample_file(file_path)

        self._do_test(name)
コード例 #6
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_new_file_after_copy(self):
        name = "new_file_after_copy"
        src_dir = self._get_source_directory(name)

        foo_path = join(src_dir, "foo")
        if exists(foo_path):
            remove(foo_path)

        obj = Pydumpfs(**self._get_pydumpfs_options())
        makedirs(self.dest_dir + src_dir)
        obj._copy_recursively(self.dest_dir, src_dir)

        self._make_sample_file(foo_path)

        obj._change_meta_data(self.dest_dir, src_dir)
コード例 #7
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_change_mode(self):
        name = "change_mode"
        src_dir = self._get_source_directory(name)
        file_path = join(src_dir, "foo")

        chmod(file_path, S_IRWXU | S_IRWXG | S_IRWXO)

        obj = Pydumpfs(**self._get_pydumpfs_options())
        backup_dir1 = obj.do(self.dest_dir, src_dir)

        chmod(file_path, S_IRUSR)

        backup_dir2 = obj.do(self.dest_dir, src_dir)

        path1 = backup_dir1 + file_path
        path2 = backup_dir2 + file_path
        self.failIf(samefile(path1, path2))
コード例 #8
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_change_gid(self):
        name = "change_gid"
        src_dir = self._get_source_directory(name)
        file_path = join(src_dir, "foo")

        self._change_gid(file_path, 1000)

        obj = Pydumpfs(**self._get_pydumpfs_options())
        backup_dir1 = obj.do(self.dest_dir, src_dir)

        self._change_gid(file_path, 0)

        backup_dir2 = obj.do(self.dest_dir, src_dir)

        path1 = backup_dir1 + file_path
        path2 = backup_dir2 + file_path
        self.failIf(samefile(path1, path2))
コード例 #9
0
ファイル: __init__.py プロジェクト: SumiTomohiko/pydumpfs
    def test_update_file(self):
        name = "update_file"
        src_dir = self._get_source_directory(name)
        file_path = join(src_dir, "foo")

        self._make_sample_file(file_path)

        obj = Pydumpfs()
        obj.do(self.dest_dir, src_dir)

        file = open(file_path, "a")
        try:
            print >> file, "bar"
        finally:
            file.close()

        self._do_test(name)