def __make_archive(self):
        target = '/tmp/work/__TEST__'
        self.assertTrue(not Directory.IsExist(target))
        Directory.Create(target)
        Directory.Create(os.path.join(target, 'A'))
        pathlib.Path(os.path.join(target, 'A/a.txt')).touch()

        Directory.Archive(target, target + '.zip')
        self.assertTrue(os.path.isfile(target + '.zip'))
        Directory.Delete(target)
Пример #2
0
    target_root = '/tmp/work/__TEST__'
    try:
        assert(True == Directory.IsExist('/'))
        assert(False == Directory.IsExist('/NotExistDir'))
        target = os.path.join(target_root, 'SUB1', 'SUB11', 'SUB111')
        print(target)
        assert('/tmp/work/__TEST__/SUB1/SUB11/SUB111' == target)
        assert(False ==  Directory.IsExist(target_root))
        Directory.Create(target)
        assert(True ==  Directory.IsExist(target))
        assert(True ==  os.path.isdir(target))
        assert(True ==  os.path.exists(target))
        
        Directory.Delete(target)
        assert(False ==  Directory.IsExist(target))
        assert(True ==  Directory.IsExist('/tmp/work/__TEST__/SUB1/SUB11'))
        
        target2 = os.path.join(target_root, '__TEST2__')
        assert(False ==  Directory.IsExist(target2))
        Directory.Copy(target_root, target2)
        assert(True ==  Directory.IsExist(target2))
        assert(True == Directory.IsExist(os.path.join(target2, 'SUB1', 'SUB11')))
        a = Directory.Archive(target_root, target_root + '.zip')
        print(a)
        print(target_root + '.zip')
        assert(a == target_root + '.zip')
        assert(os.path.isfile(a))
    finally:
        Directory.Delete(target_root)
        os.remove(target_root + '.zip')