def test_archive_pos(self): test_path_dest = os.path.dirname(os.path.realpath(__file__)) test_path_src = os.path.join(test_path_dest, "input") TaskController._archive_source(test_path_src, test_path_dest) arch_tar = tarfile.open(os.path.join(test_path_dest, "archive.tar.gz")) self.FILES_TO_REMOVE.append(arch_tar.name) filenames = arch_tar.getnames() self.assertIn("app.py", filenames) self.assertIn("README.md", filenames) self.assertIn("data/readme.txt", filenames) self.assertIn("data/subsub/test.rst", filenames) self.assertIn("imgs/tester.png", filenames)
def test_archive_pos_filter(self): test_path_dest = os.path.dirname(os.path.realpath(__file__)) test_path_src = os.path.join(test_path_dest, "input") filter_file = os.path.join(test_path_src, TaskController.IGNORE_FILES_NAME) self.FILES_TO_REMOVE.append(filter_file) with open(filter_file, "a") as f: f.write("imgs/\n") f.write("README.md\n") TaskController._archive_source(test_path_src, test_path_dest) arch_tar = tarfile.open(os.path.join(test_path_dest, "archive.tar.gz")) self.FILES_TO_REMOVE.append(arch_tar.name) filenames = arch_tar.getnames() self.assertIn("app.py", filenames) self.assertNotIn("README.md", filenames) self.assertIn("data/readme.txt", filenames) self.assertIn("data/subsub/test.rst", filenames) self.assertNotIn("imgs/tester.png", filenames)