class RemoveTest(unittest.TestCase): def setUp(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass self.copy_compiler = Copy(compile_path, search_path, ref_controller) self.remove_compiler = Remove(compile_path, search_path, ref_controller) def test_remove_file_folder(self): test_dirs_bootstrap_helper() self.copy_compiler.compile_file(test_file_path, compile_path, None) self.assertTrue(os.path.exists(test_file_compiled_path)) self.remove_compiler.compile_file(test_file_compiled_path, compile_path, None) self.assertFalse(os.path.exists(test_file_compiled_path)) def test_remove_folder_folder(self): test_dirs_bootstrap_helper() self.copy_compiler.compile_file(file_path, compile_path, None) self.assertTrue(os.path.exists(compile_path)) self.remove_compiler.compile_file(compile_path, compile_path, None) self.assertFalse(os.path.exists(compile_path)) def tearDown(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass
class CopyTest(unittest.TestCase): def setUp(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass self.copy_compiler = Copy(compile_path, search_path, ref_controller) def test_copy_file_folder(self): test_dirs_bootstrap_helper() self.copy_compiler.compile_file(test_file_path, compile_path, None) self.test_file_hash = hashlib.sha1(test_file_content.encode()).digest() with open(test_file_compiled_path) as f: test_file_compiled_hash = hashlib.sha1(f.read().encode()).digest() self.assertEqual(self.test_file_hash, test_file_compiled_hash) def test_copy_folder_folder(self): test_dirs_bootstrap_helper() self.copy_compiler.compile_file(file_path, compile_path, None) file_path_hash = directory_hash(file_path) compile_path_hash = directory_hash(compile_path) self.assertEqual(file_path_hash, compile_path_hash) def tearDown(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass
class CopyMissingFileTest(unittest.TestCase): def setUp(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass self.copy_compiler = Copy(compile_path, search_path, ref_controller, ignore_missing=True) def test_copy_missing_path_folder(self): test_dirs_bootstrap_helper() self.copy_compiler.compile_file(test_file_missing_path, compile_path, None) def tearDown(self): try: shutil.rmtree(test_path) except FileNotFoundError: pass