def test_mv_tree(self):
        target = '/tmp/work/__TEST__/a.txt'
        self.assertTrue(not File.IsExist(target))
        self.assertTrue(not File.IsExist('/tmp/work/__TEST_2__/a.txt'))

        d = File(target)
        self.assertEqual(target, d.Path)
        with self.assertRaises(FileNotFoundError) as e:
            d.mv('/tmp/work/__TEST_2__/a.txt')

        d.mk('B/b.txt')
        self.assertEqual(target, d.Path)
        self.assertTrue(File.IsExist('/tmp/work/__TEST__/B/b.txt'))

        self.assertTrue(not File.IsExist('/tmp/work/__TEST__/a.txt'))
        d.mk()

        d.mv('/tmp/work/__TEST_2__/a.txt')
        self.assertEqual('/tmp/work/__TEST_2__/a.txt', d.Path)
        self.assertTrue(File.IsExist('/tmp/work/__TEST_2__/a.txt'))
        self.assertTrue(not File.IsExist(target))
        self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
        self.assertTrue(not File.IsExist('/tmp/work/__TEST_2__/B/b.txt'))
        Directory.Delete('/tmp/work/__TEST_2__')
        Directory.Delete('/tmp/work/__TEST__')
    def test_mv_tree(self):
        target = '/tmp/work/__TEST__'
        self.assertTrue(not Directory.IsExist(target))
        self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))

        d = Directory(target)
        self.assertEqual(target, d.Path)
        with self.assertRaises(FileNotFoundError) as e:
            d.mv('/tmp/work/__TEST_2__')

        #d.mk()
        d.mk('A')
        self.assertEqual(target, d.Path)
        pathlib.Path(os.path.join(target, 'A/a.txt')).touch()
        self.assertTrue(Directory.IsExist('/tmp/work/__TEST__/A'))
        self.assertTrue(os.path.isfile('/tmp/work/__TEST__/A/a.txt'))

        d.mv('/tmp/work/__TEST_2__')
        self.assertEqual('/tmp/work/__TEST_2__', d.Path)
        self.assertTrue(not Directory.IsExist(target))
        self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
        self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__/A'))
        self.assertTrue(os.path.isfile('/tmp/work/__TEST_2__/A/a.txt'))
        Directory.Delete('/tmp/work/__TEST_2__')
        Directory.Delete('/tmp/work/__TEST__')
 def test_Copy_single(self):
     target = '/tmp/work/__TEST__'
     self.assertTrue(not Directory.IsExist(target))
     Directory.Create(target)
     Directory.Copy(target, '/tmp/work/__TEST_2__')
     self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
     Directory.Delete(target)
     Directory.Delete('/tmp/work/__TEST_2__')
 def test_Move_single(self):
     target = '/tmp/work/__TEST__/a.txt'
     self.assertTrue(not File.IsExist(target))
     self.assertTrue(not File.IsExist('/tmp/work/__TEST_2__'))
     File.Create(target)
     File.Move(target, '/tmp/work/__TEST_2__/b.txt')
     self.assertTrue(not File.IsExist(target))
     self.assertTrue(File.IsExist('/tmp/work/__TEST_2__/b.txt'))
     Directory.Delete('/tmp/work/__TEST_2__')
     Directory.Delete('/tmp/work/__TEST__')
 def test_Copy_tree(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()
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))
     Directory.Copy(target, '/tmp/work/__TEST_2__')
     self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
     self.assertTrue(os.path.isfile('/tmp/work/__TEST_2__/A/a.txt'))
     Directory.Delete(target)
     Directory.Delete('/tmp/work/__TEST_2__')
 def test_Create_Delete(self):
     target = '/tmp/work/__TEST__'
     self.assertTrue(not Directory.IsExist(target))
     Directory.Create(target)
     self.assertTrue(Directory.IsExist(target))
     Directory.Delete(target)
     self.assertTrue(not Directory.IsExist(target))
     target = '/tmp/work/__TEST__/A/B/C'
     self.assertTrue(not Directory.IsExist(target))
     Directory.Create(target)
     self.assertTrue(Directory.IsExist(target))
     Directory.Delete(target)
     self.assertTrue(not Directory.IsExist(target))
     target = '/tmp/work/__TEST__'
     Directory.Delete(target)
 def test_mk_dummy(self):
     target_root = '/tmp/work/__TEST__'
     target = '/tmp/work/__TEST__/a.txt'
     d = File(target)
     self.assertTrue(not File.IsExist(target_root))
     self.assertTrue(d.Stat is None)
     d.mk_dummy(1024)
     self.assertEqual(target, d.Path)
     self.assertEqual(1024, d.Size)
     self.assertTrue(File.IsExist(target))
     self.assertTrue(not File.IsExist(os.path.join(target_root, 'A/a.txt')))
     d.mk_dummy(2048, 'A/a.txt')
     self.assertEqual(target, d.Path)
     self.assertEqual(2048, File.GetSize('/tmp/work/__TEST__/A/a.txt'))
     self.assertTrue(File.IsExist(os.path.join(target_root, 'A/a.txt')))
     self.assertTrue(
         not File.IsExist(os.path.join(target_root, 'B/BB/BBB/b.txt')))
     d.mk_dummy(3072, 'B/BB/BBB/b.txt')
     self.assertEqual(target, d.Path)
     #self.assertEqual(3072, d.Size)
     self.assertEqual(3072,
                      File.GetSize('/tmp/work/__TEST__/B/BB/BBB/b.txt'))
     self.assertTrue(
         File.IsExist(os.path.join(target_root, 'B/BB/BBB/b.txt')))
     self.assertTrue(
         not File.IsExist(os.path.join('/tmp/work/__TEST__/C/c.txt')))
     d.mk_dummy(4096, '/tmp/work/__TEST__/C/c.txt')
     self.assertEqual(target, d.Path)
     #self.assertEqual(4096, d.Size)
     self.assertEqual(4096, File.GetSize('/tmp/work/__TEST__/C/c.txt'))
     self.assertTrue(
         File.IsExist(os.path.join('/tmp/work/__TEST__/C/c.txt')))
     Directory.Delete('/tmp/work/__TEST__')
    def test_Copy(self):
        target = '/tmp/work/__TEST__/a.txt'
        self.assertTrue(not File.IsExist(target))
        File.CreateDummy(target, 1024)
        File.Copy(target, '/tmp/work/__TEST__/b.txt')
        self.assertTrue(File.IsExist('/tmp/work/__TEST__/b.txt'))
        self.assertTrue(1024 == File.GetSize('/tmp/work/__TEST__/a.txt'))
        self.assertTrue(1024 == File.GetSize('/tmp/work/__TEST__/b.txt'))

        self.assertTrue(not os.path.exists('/tmp/work/__TEST_2__'))
        with self.assertRaises(IsADirectoryError) as e:
            File.Copy('/tmp/work/__TEST__', '/tmp/work/__TEST_2__')

        self.assertTrue(not os.path.exists('/tmp/work/__TEST_2__'))
        with self.assertRaises(IsADirectoryError) as e:
            File.Copy('/tmp/work/__TEST__', '/tmp/work/__TEST_2__/c.txt')

        self.assertTrue(not os.path.exists('/tmp/work/__TEST_2__/c.txt'))
        File.Copy('/tmp/work/__TEST__/a.txt', '/tmp/work/__TEST_2__')
        self.assertTrue(os.path.exists('/tmp/work/__TEST_2__'))
        self.assertTrue(1024 == File.GetSize('/tmp/work/__TEST_2__'))

        File.Delete('/tmp/work/__TEST__/a.txt')
        File.Delete('/tmp/work/__TEST__/b.txt')
        File.Delete('/tmp/work/__TEST_2__')
        Directory.Delete('/tmp/work/__TEST__')
    def test_Accessed(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        File.CreateDummy(target_dummy, 1024)

        s = File(target_root)
        self.assertTrue(tuple == type(s.Accessed))
        self.assertTrue(2 == len(s.Accessed))
        self.assertTrue(float == type(s.Accessed[0]))
        self.assertTrue(datetime.datetime == type(s.Accessed[1]))
        dt1 = datetime.datetime.strptime('1999/12/31 23:59:59',
                                         '%Y/%m/%d %H:%M:%S')
        dt2 = datetime.datetime.strptime('2345/01/02 12:34:56',
                                         '%Y/%m/%d %H:%M:%S')
        epoch, dt = s.Accessed
        self.assertTrue(dt1 != dt)
        self.assertTrue(dt2 != dt)

        s.Accessed = dt1
        self.assertTrue(int(time.mktime(dt1.timetuple())) == s.Accessed[0])
        self.assertTrue(dt1 == s.Accessed[1])
        self.assertTrue(dt1 != s.Modified[1])
        self.assertTrue(dt1 != s.Created[1])
        self.assertTrue(dt1 != s.ChangedMeta[1])
        Directory.Delete(target_root)
    def test_Modified_Get_Set(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        File.CreateDummy(target_dummy, 1024)

        self.assertTrue(tuple == type(File.GetModified(target_dummy)))
        self.assertTrue(2 == len(File.GetModified(target_dummy)))
        self.assertTrue(float == type(File.GetModified(target_dummy)[0]))
        self.assertTrue(
            datetime.datetime == type(File.GetModified(target_dummy)[1]))
        #print(type(File.GetModified(target_dummy)[0]))
        #print(type(File.GetModified(target_dummy)[1]))
        dt1 = datetime.datetime.strptime('1999/12/31 23:59:59',
                                         '%Y/%m/%d %H:%M:%S')
        dt2 = datetime.datetime.strptime('2345/01/02 12:34:56',
                                         '%Y/%m/%d %H:%M:%S')
        epoch, dt = File.GetModified(target_dummy)
        self.assertTrue(dt1 != dt)
        self.assertTrue(dt2 != dt)

        File.SetModified(target_dummy, dt1)
        self.assertTrue(
            int(time.mktime(dt1.timetuple())) == File.GetModified(target_dummy)
            [0])
        self.assertTrue(dt1 == File.GetModified(target_dummy)[1])
        self.assertTrue(dt1 != File.GetChangedMeta(target_dummy)[1])
        self.assertTrue(dt1 != File.GetAccessed(target_dummy)[1])
        Directory.Delete(target_root)
    def test_Size(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        self.__MakeDummy(target_dummy, 1024)

        #s = Directory(target_root)
        s = Directory(target_root)
        self.assertEqual(1024, s.Size)

        path_b = os.path.join(target_root, 'B')
        Directory.Create(path_b)
        self.__MakeDummy(os.path.join(path_b, 'b.dummy'), 1024)
        self.assertEqual(2048, s.Size)

        path_c = os.path.join(target_root, 'C')
        Directory.Create(path_c)
        self.__MakeDummy(os.path.join(path_c, 'c.dummy'), 1024)
        self.assertEqual(3072, s.Size)

        path_bb = os.path.join(target_root, 'B/BB')
        Directory.Create(path_bb)
        self.__MakeDummy(os.path.join(path_bb, 'bb.dummy'), 1024)
        self.assertEqual(4096, s.Size)

        Directory.Delete(target_root)
 def test_mk_rm(self):
     target_root = '/tmp/work/__TEST__'
     target = '/tmp/work/__TEST__/a.txt'
     d = File(target)
     self.assertTrue(not File.IsExist(target))
     d.mk()
     self.assertEqual(target, d.Path)
     self.assertTrue(File.IsExist(target))
     self.assertTrue(not File.IsExist(os.path.join(target_root, 'A/a.txt')))
     d.mk('A/a.txt')
     self.assertEqual(target, d.Path)
     self.assertTrue(File.IsExist(os.path.join(target_root, 'A/a.txt')))
     self.assertTrue(
         not File.IsExist(os.path.join(target_root, 'B/BB/BBB/b.txt')))
     d.mk('B/BB/BBB/b.txt')
     self.assertEqual(target, d.Path)
     self.assertTrue(
         File.IsExist(os.path.join(target_root, 'B/BB/BBB/b.txt')))
     self.assertTrue(
         not File.IsExist(os.path.join('/tmp/work/__TEST__/C/c.txt')))
     d.mk('/tmp/work/__TEST__/C/c.txt')
     self.assertEqual(target, d.Path)
     self.assertTrue(
         File.IsExist(os.path.join('/tmp/work/__TEST__/C/c.txt')))
     d.rm()
     Directory.Delete('/tmp/work/__TEST__')
    def test_Path(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        self.__MakeDummy(target_dummy, 1024)

        s = Directory(target_root)
        self.assertEqual('/tmp/work/__TEST__', s.Path)
        Directory.Delete(target_root)
 def test_UnArchive(self):
     self.__make_archive()
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST__'))
     Directory.UnArchive('/tmp/work/__TEST__.zip')
     self.assertTrue(Directory.IsExist('/tmp/work/__TEST__'))
     self.assertTrue(Directory.IsExist('/tmp/work/__TEST__/A'))
     self.assertTrue(os.path.isfile('/tmp/work/__TEST__/A/a.txt'))
     Directory.Delete('/tmp/work/__TEST__')
     os.remove('/tmp/work/__TEST__.zip')
    def test_Stat(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        self.__MakeDummy(target_dummy, 1024)

        s = Directory(target_root)
        self.assertEqual(Directory, type(s))
        self.assertEqual(os.stat_result, type(s.Stat))
        Directory.Delete(target_root)
 def test_GetChangedMeta(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     self.assertTrue(hasattr(Directory, 'GetChangedMeta'))
     self.assertTrue(hasattr(Directory, 'GetCreated'))
     print(Directory.GetChangedMeta(target_dummy))
     print(Directory.GetCreated(target_dummy))
     Directory.Delete(target_root)
    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)
 def test_ChangedMeta(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     s = Directory(target_root)
     self.assertTrue(hasattr(s, 'ChangedMeta'))
     self.assertTrue(hasattr(s, 'Created'))
     print(s.ChangedMeta)
     print(s.Created)
     Directory.Delete(target_root)
 def test_DiskUsage(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     self.assertTrue(hasattr(Directory, 'DiskUsage'))
     res = Directory.DiskUsage(target_dummy)
     self.assertTrue(hasattr(res, 'total'))
     self.assertTrue(hasattr(res, 'used'))
     self.assertTrue(hasattr(res, 'free'))
     print(Directory.DiskUsage(target_dummy))
     Directory.Delete(target_root)
 def test_cp_single(self):
     target_root = '/tmp/work/__TEST__'
     d = Directory(target_root)
     self.assertEqual(target_root, d.Path)
     self.assertTrue(not Directory.IsExist(target_root))
     d.mk()
     self.assertEqual(target_root, d.Path)
     self.assertTrue(Directory.IsExist(target_root))
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))
     res = d.cp('/tmp/work/__TEST_2__')
     self.assertEqual(target_root, d.Path)
     self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
     self.assertEqual('/tmp/work/__TEST_2__', res)
     self.assertEqual('/tmp/work/__TEST__', d.Path)
     d.rm()
     self.assertEqual(target_root, d.Path)
     Directory.Delete('/tmp/work/__TEST__')
     Directory.Delete('/tmp/work/__TEST_2__')
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST__'))
 def test_SetModeFromName_Error(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     File.CreateDummy(target_dummy, 1024)
     mode_name = 'Invalid-Text'
     with self.assertRaises(ValueError) as e:
         File.SetMode(target_dummy, mode_name)
     mode_names = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx']
     self.assertEqual(
         '引数mode_nameが不正値です。\'{}\'。\'-rwxrwxrwx\'の書式で入力してください。owner, group, other, の順に次のパターンのいずれかを指定します。pattern={}。r,w,xはそれぞれ、読込、書込、実行の権限です。-は権限なしを意味します。'
         .format(mode_name, mode_names), e.exception.args[0])
     Directory.Delete(target_root)
    def test_mv_single(self):
        target = '/tmp/work/__TEST__'
        self.assertTrue(not Directory.IsExist(target))
        self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))

        d = Directory(target)
        self.assertEqual(target, d.Path)
        with self.assertRaises(FileNotFoundError) as e:
            d.mv('/tmp/work/__TEST_2__')

        d.mk()
        self.assertEqual(target, d.Path)
        self.assertTrue(Directory.IsExist(target))
        self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))

        d.mv('/tmp/work/__TEST_2__')
        self.assertEqual('/tmp/work/__TEST_2__', d.Path)
        self.assertTrue(not Directory.IsExist(target))
        self.assertTrue(Directory.IsExist('/tmp/work/__TEST_2__'))
        Directory.Delete('/tmp/work/__TEST_2__')
        Directory.Delete('/tmp/work/__TEST__')
 def test_cp_tree(self):
     target_root = '/tmp/work/__TEST__'
     target = '/tmp/work/__TEST__/a.txt'
     d = File(target)
     self.assertEqual(target, d.Path)
     self.assertTrue(not File.IsExist(d.Path))
     with self.assertRaises(FileNotFoundError) as e:
         d.cp('/tmp/work/__TEST_2__/a.txt')
     d.mk()
     self.assertEqual(target, d.Path)
     self.assertTrue(File.IsExist(d.Path))
     d.mk('A/a.txt')
     self.assertEqual(target, d.Path)
     self.assertTrue(not Directory.IsExist('/tmp/work/__TEST_2__'))
     d.cp('/tmp/work/__TEST_2__/A/a.txt')
     self.assertEqual(target, d.Path)
     self.assertTrue(File.IsExist('/tmp/work/__TEST_2__/A/a.txt'))
     d.rm()
     self.assertEqual(target, d.Path)
     Directory.Delete('/tmp/work/__TEST_2__')
     Directory.Delete('/tmp/work/__TEST__')
     self.assertTrue(not File.IsExist('/tmp/work/__TEST__'))
     self.assertTrue(not File.IsExist('/tmp/work/__TEST_2__'))
 def test_Ids(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     self.assertTrue(hasattr(Directory, 'OwnUserId'))
     self.assertTrue(hasattr(Directory, 'OwnGroupId'))
     self.assertTrue(hasattr(Directory, 'HardLinkNum'))
     self.assertTrue(hasattr(Directory, 'INode'))
     self.assertTrue(hasattr(Directory, 'DeviceId'))
     print(Directory.GetOwnUserId(target_dummy))
     print(Directory.GetOwnGroupId(target_dummy))
     print(Directory.GetHardLinkNum(target_dummy))
     print(Directory.GetINode(target_dummy))
     print(Directory.GetDeviceId(target_dummy))
     Directory.Delete(target_root)
 def test_mk_rm_raise(self):
     target_root = '/tmp/work/__TEST__'
     target = '/tmp/work/__TEST__/a.txt'
     d = File(target)
     self.assertTrue(not File.IsExist(target_root))
     with self.assertRaises(ValueError) as e:
         d.mk('/tmp/work/A')
     self.assertEqual(
         '引数pathは未指定か次のパスの相対パス、または次のパス配下を指定してください。{}'.format(target_root),
         e.exception.args[0])
     with self.assertRaises(ValueError) as e:
         d.rm('/tmp/work/A')
     self.assertEqual(
         '引数pathは未指定か次のパスの相対パス、または次のパス配下を指定してください。{}'.format(target_root),
         e.exception.args[0])
     Directory.Delete('/tmp/work/__TEST__')
 def test_Create_Delete(self):
     target = '/tmp/work/__TEST__/a.txt'
     self.assertTrue(not File.IsExist(target))
     File.Create(target)
     self.assertTrue(File.IsExist(target))
     self.assertTrue(0 == File.GetSize(target))
     File.Delete(target)
     self.assertTrue(not File.IsExist(target))
     target = '/tmp/work/__TEST__/A/B/C/d.e'
     self.assertTrue(not File.IsExist(target))
     File.Create(target)
     self.assertTrue(File.IsExist(target))
     File.Delete(target)
     self.assertTrue(not File.IsExist(target))
     target = '/tmp/work/__TEST__'
     Directory.Delete(target)
 def test_Ids_Property(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     s = Directory(target_root)
     self.assertTrue(hasattr(s, 'OwnUserId'))
     self.assertTrue(hasattr(s, 'OwnGroupId'))
     self.assertTrue(hasattr(s, 'HardLinkNum'))
     self.assertTrue(hasattr(s, 'INode'))
     self.assertTrue(hasattr(s, 'DeviceId'))
     print(s.OwnUserId)
     print(s.OwnGroupId)
     print(s.HardLinkNum)
     print(s.INode)
     print(s.DeviceId)
     Directory.Delete(target_root)
    def test_Mode(self):
        target_root = '/tmp/work/__TEST__'
        target_dummy = os.path.join(target_root, 'a.dummy')
        self.__MakeDummy(target_dummy, 1024)

        s = Directory(target_root)
        s.Mode = 0o777
        self.assertEqual(0o40777, s.Mode)
        self.assertEqual('drwxrwxrwx', s.ModeName)
        s.Mode = 0o644
        self.assertEqual(0o40644, s.Mode)
        self.assertEqual('drw-r--r--', s.ModeName)
        s.Mode = '-rwxrwxrwx'
        self.assertEqual(0o40777, s.Mode)
        self.assertEqual('drwxrwxrwx', s.ModeName)
        Directory.Delete(target_root)
 def test_Mode_Get_Set_Name(self):
     target_root = '/tmp/work/__TEST__'
     target_dummy = os.path.join(target_root, 'a.dummy')
     self.__MakeDummy(target_dummy, 1024)
     mode = Directory.GetMode(target_dummy)
     print(mode)
     print(oct(mode))
     Directory.SetMode(target_dummy, 0o755)
     self.assertEqual(0o100755, Directory.GetMode(target_dummy))
     self.assertEqual('-rwxr-xr-x', Directory.GetModeName(target_dummy))
     Directory.SetMode(target_dummy, '-rwxrwxrwx')
     self.assertEqual(0o100777, Directory.GetMode(target_dummy))
     Directory.SetMode(target_dummy, 0o644)
     self.assertEqual(0o100644, Directory.GetMode(target_dummy))
     self.assertEqual('-rw-r--r--', Directory.GetModeName(target_dummy))
     Directory.Delete(target_root)
    def __make_pack(self):
        target = '/tmp/work/__TEST__'
        self.assertTrue(not Directory.IsExist(target))

        d = Directory(target)
        d.mk('A')
        pathlib.Path(os.path.join(target, 'A/a.txt')).touch()
        
        self.assertTrue(not os.path.isfile(target + '.zip'))
        d.pack(target + '.zip')
        self.assertTrue(os.path.isfile(target + '.zip'))
        self.assertEqual(target, d.Path)

        d.rm()
        self.assertTrue(not Directory.IsExist(target))
        Directory.Delete(target)
        return d