def test_move_all_files_4(self): dh.move_all_files(self.d_d, self.root) root_files = dh.list_only_files(self.root) d_files = dh.list_only_files(self.d_d) self.assertEqual(len(root_files), 2) self.assertEqual(len(d_files), 0) self.assertIn(self.f_1, root_files) self.assertIn(self.f_2, root_files)
def test_move_all_files_1(self): dh.move_all_files(self.root, self.d_d) root_files = dh.list_only_files(self.root) d_files = dh.list_only_files(self.d_d) self.assertEqual(len(root_files), 0) self.assertEqual(len(d_files), 2) self.assertIn(self.d_d / self.f_1.name, d_files) self.assertIn(self.d_d / self.f_2.name, d_files)
def test_move_all_files_3(self): dir_1 = Path("asdf") dir_2 = Path("ghi") target = self.root / dir_1 / dir_2 dh.move_all_files(self.root, target) root_files = dh.list_only_files(self.root) self.assertEqual(len(root_files), 0) files_in_asdf = dh.list_only_files(self.root / dir_1) self.assertEqual(len(files_in_asdf), 0) self.assertTrue(dh.is_existing_directory(target)) target_files = dh.list_only_files(target) self.assertEqual(len(target_files), 2) self.assertIn(target / self.f_1.name, target_files) self.assertIn(target / self.f_2.name, target_files)
def test_move_all_files_5(self): dh.move_all_files(self.root, self.root) root_files = dh.list_only_files(self.root) self.assertEqual(len(root_files), 2) self.assertIn(self.f_1, root_files) self.assertIn(self.f_2, root_files)
def test_move_all_files_2(self): dh.move_all_files(self.d_a, self.root) a_files = dh.list_files_recursively(self.d_a) self.assertEqual(len(a_files), 1) self.assertIn(self.f_5, a_files) root_files = dh.list_only_files(self.root) self.assertEqual(len(root_files), 4) self.assertIn(self.f_1, root_files) self.assertIn(self.f_2, root_files) self.assertIn(self.root / self.f_3.name, root_files) self.assertIn(self.root / self.f_4.name, root_files)
def test_list_only_files(self): fls = dh.list_only_files(self.root) self.assertEqual(len(fls), 2) self.assertIn(self.f_1, fls) self.assertIn(self.f_2, fls) fls = dh.list_only_files(self.d_a) self.assertEqual(len(fls), 2) self.assertIn(self.f_3, fls) self.assertIn(self.f_4, fls) fls = dh.list_only_files(self.d_c) self.assertEqual(len(fls), 1) self.assertIn(self.f_5, fls) fls = dh.list_only_files(self.d_b) self.assertEqual(len(fls), 1) self.assertIn(self.f_6, fls) fls = dh.list_only_files(self.d_d) self.assertEqual(len(fls), 0) self.assertRaises(NotADirectoryError, dh.list_only_files, self.not_existing) self.assertRaises(NotADirectoryError, dh.list_only_files, self.f_1)