Exemplo n.º 1
0
 def del_tmp(self):
     """Remove all files from test directory"""
     config.set_environ("FTP_PASSWORD", self.password)
     backend = duplicity.backend.get_backend(self.url_string)
     backend.delete(backend.list())
     backend.close()
     """Delete and create testfiles/output"""
     assert not os.system("rm -rf testfiles/output")
     assert not os.system("mkdir testfiles/output")
Exemplo n.º 2
0
 def del_tmp(self):
     """Remove all files from test directory"""
     config.set_environ("FTP_PASSWORD", self.password)
     backend = duplicity.backend.get_backend(self.url_string)
     backend.delete(backend.list())
     backend.close()
     """Delete and create testfiles/output"""
     assert not os.system("rm -rf testfiles/output")
     assert not os.system("mkdir testfiles/output")
Exemplo n.º 3
0
 def deltmp(self):
     """Delete temporary directories"""
     assert not os.system("rm -rf testfiles/output "
                          "testfiles/restore_out testfiles/cache")
     assert not os.system("mkdir testfiles/output testfiles/cache")
     backend = duplicity.backend.get_backend(backend_url)
     bl = backend.list()
     if bl:
         backend.delete(backend.list())
     backend.close()
Exemplo n.º 4
0
 def deltmp(self):
     """Delete temporary directories"""
     assert not os.system("rm -rf testfiles/output "
                          "testfiles/restore_out testfiles/cache")
     assert not os.system("mkdir testfiles/output testfiles/cache")
     backend = duplicity.backend.get_backend(backend_url)
     bl = backend.list()
     if bl:
         backend.delete(backend.list())
     backend.close()
Exemplo n.º 5
0
 def setUp(self):
     self.class_args = []
     assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
     assert not os.system("rm -rf testfiles/output testfiles/largefiles " "testfiles/restore_out testfiles/cache")
     assert not os.system("mkdir testfiles/output testfiles/cache")
     backend = duplicity.backend.get_backend(backend_url)
     bl = backend.list()
     if bl:
         backend.delete(backend.list())
     backend.close()
Exemplo n.º 6
0
 def setUp(self):
     self.class_args = []
     assert not os.system("tar xzf testfiles.tar.gz > /dev/null 2>&1")
     assert not os.system("rm -rf testfiles/output testfiles/largefiles "
                          "testfiles/restore_out testfiles/cache")
     assert not os.system("mkdir testfiles/output testfiles/cache")
     backend = duplicity.backend.get_backend(backend_url)
     bl = backend.list()
     if bl:
         backend.delete(backend.list())
     backend.close()
Exemplo n.º 7
0
    def try_fileobj_filename(self, backend, filename):
        """Use get_fileobj_write and get_fileobj_read on filename around"""
        fout = backend.get_fileobj_write(filename)
        fout.write("hello, world!")
        fout.close()
        assert filename in backend.list()

        fin = backend.get_fileobj_read(filename)
        buf = fin.read()
        fin.close()
        assert buf == "hello, world!", buf

        backend.delete ([filename])
Exemplo n.º 8
0
    def try_fileobj_filename(self, backend, filename):
        """Use get_fileobj_write and get_fileobj_read on filename around"""
        fout = backend.get_fileobj_write(filename)
        fout.write("hello, world!")
        fout.close()
        assert filename in backend.list()

        fin = backend.get_fileobj_read(filename)
        buf = fin.read()
        fin.close()
        assert buf == "hello, world!", buf

        backend.delete ([filename])
Exemplo n.º 9
0
    def try_basic(self, backend):
        """Try basic operations with given backend.

        Requires backend be empty at first, and all operations are
        allowed.

        """
        def cmp_list(l):
            """Assert that backend.list is same as l"""
            blist = backend.list()
            blist.sort()
            l.sort()
            assert blist == l, \
                   ("Got list: %s\nWanted: %s\n" % (repr(blist), repr(l)))

        # Identify test that's running
        print self.my_test_id, "... ",

        assert not os.system("rm -rf testfiles/backend_tmp")
        assert not os.system("mkdir testfiles/backend_tmp")

        regpath = path.Path("testfiles/various_file_types/regular_file")
        normal_file = "testfile"
        colonfile = ("file%swith.%scolons_-and%s%setc" %
                     ((globals.time_separator,) * 4))
        tmpregpath = path.Path("testfiles/backend_tmp/regfile")

        # Test list and put
        cmp_list([])
        backend.put(regpath, normal_file)
        cmp_list([normal_file])
        backend.put(regpath, colonfile)
        cmp_list([normal_file, colonfile])

        # Test get
        regfilebuf = regpath.open("rb").read()
        backend.get(colonfile, tmpregpath)
        backendbuf = tmpregpath.open("rb").read()
        assert backendbuf == regfilebuf

        # Test delete
        backend.delete([colonfile, normal_file])
        cmp_list([])
Exemplo n.º 10
0
    def try_basic(self, backend):
        """Try basic operations with given backend.

        Requires backend be empty at first, and all operations are
        allowed.

        """
        def cmp_list(l):
            """Assert that backend.list is same as l"""
            blist = backend.list()
            blist.sort()
            l.sort()
            assert blist == l, \
                   ("Got list: %s  Wanted: %s\n" % (repr(blist), repr(l)))

        # Identify test that's running
        print self.my_test_id, "... ",

        assert not os.system("rm -rf testfiles/backend_tmp")
        assert not os.system("mkdir testfiles/backend_tmp")

        regpath = path.Path("testfiles/various_file_types/regular_file")
        normal_file = "testfile"
        colonfile = ("file%swith.%scolons_-and%s%setc" %
                     ((globals.time_separator,) * 4))
        tmpregpath = path.Path("testfiles/backend_tmp/regfile")

        # Test list and put
        cmp_list([])
        backend.put(regpath, normal_file)
        cmp_list([normal_file])
        backend.put(regpath, colonfile)
        cmp_list([normal_file, colonfile])

        # Test get
        regfilebuf = regpath.open("rb").read()
        backend.get(colonfile, tmpregpath)
        backendbuf = tmpregpath.open("rb").read()
        assert backendbuf == regfilebuf

        # Test delete
        backend.delete([colonfile, normal_file])
        cmp_list([])