def test_guess_action_clean(self): self.empty_folder() os.makedirs('node_modules') os.makedirs('vendor') compileman = CompileMan() expected_result = 'clean' self.assertEqual(expected_result, compileman.guess_action())
def test_clean_project_type_node(self): os.makedirs('node_modules') os.makedirs('vendor') compileman = CompileMan() compileman.clean_project_type('node') files_in_directory = os.listdir() cleaned = not 'node_modules' in files_in_directory self.assertTrue(cleaned)
def test_clean_project_type_php(self): self.empty_folder() os.makedirs('node_modules') os.makedirs('vendor') compileman = CompileMan() compileman.clean_project_type('php') files_in_directory = os.listdir() cleaned = not 'vendor' in files_in_directory self.assertTrue(cleaned)
def test_clean_project_type_node_vendor_kept(self): self.empty_folder() os.makedirs('node_modules') os.makedirs('vendor') compileman = CompileMan() compileman.clean_project_type('node') files_in_directory = os.listdir() kept = 'vendor' in files_in_directory self.assertTrue(kept)
def cman(): compileman = CompileMan() commands = Commands(sys.argv) if not commands.is_command_given(): command = compileman.guess_action() else: command = commands.get_command_given() if command == '': print('You have not provided any command and it was not possible to guess. Tell if you want to compile or clean the compiled assets typing \'compile\' or \'clean\'.') exit() project_types = compileman.get_project_types() if command == 'compile': can_compile = compileman.cancompile(project_types) if not can_compile: for reasons in compileman.get_cannot_compile_reasons(): print(reasons) else: for project_type in project_types: print("Compiling to project type of " + project_type) compileman.compile(project_type) if command == 'clean': for compilling_type in project_types: print("Removing project of type " + compilling_type) results = compileman.clean_project_type(compilling_type) if results.getResult(): resultMessage = "The project " + compilling_type + " has been removed." else: resultMessage = results.getErrorMessage() print(resultMessage)
def test_check_project_types(self): compileman = CompileMan() project_types = compileman.get_project_types() expected_project_types = [] self.assertListEqual(expected_project_types, project_types)
def test_clean_wrong_type(self): compileman = CompileMan() with self.assertRaises(Exception): compileman.clean(['non_existent'])
def test_cancompile_empty_compilations(self): compileman = CompileMan() can_compile = compileman.cancompile([]) self.assertFalse(can_compile)
def test_cancompile_wrong_data(self): compileman = CompileMan() with self.assertRaises(Exception): compileman.cancompile(['not_valid'])
def test_guess_action_compile(self): self.empty_folder() expected_result = 'compile' compileman = CompileMan() self.assertEqual(expected_result, compileman.guess_action())
def test_guess_action_doubt_vendor(self): self.empty_folder() os.makedirs('vendor') compileman = CompileMan() expected_result = '' self.assertEqual(expected_result, compileman.guess_action())
def test_is_vendor_exists_false(self): self.empty_folder() compileman = CompileMan() self.assertFalse(compileman.is_vendor_exists())
def test_is_node_module_exists(self): self.empty_folder() os.makedirs('node_modules') compileman = CompileMan() self.assertTrue(compileman.is_node_module_exists())
def test_is_node_module_exists_false(self): self.empty_folder() compileman = CompileMan() self.assertFalse(compileman.is_node_module_exists())
def test_is_posix_true_2(self): compileman = CompileMan() is_posix_result = compileman.is_posix('linux2') self.assertTrue(is_posix_result)
def test_exception_wrong_platform_invalid(self): compileman = CompileMan() platform = 'unknown_platform' with self.assertRaises(Exception): compileman.exception_wrong_platform(platform)
def test_universal_subprocess_call_exception(self): compileman = CompileMan() with self.assertRaises(Exception): compile.universal_subprocess_call(['dir'], 'unknown_platform')
def test_is_posix_exception_invalid_name(self): compileman = CompileMan() with self.assertRaises(Exception): compileman.is_posix('not_valid')
def test_clean_project_type_return(self): compileman = CompileMan() clean_compile_result = compileman.clean_project_type('php') self.assertTrue(isinstance(clean_compile_result, Compile_Result))
def test_is_posix_false(self): compileman = CompileMan() is_posix_result = compileman.is_posix('win32') self.assertFalse(is_posix_result)
def test_is_vendor_exists(self): self.empty_folder() os.makedirs('vendor') compileman = CompileMan() self.assertTrue(compileman.is_vendor_exists())
def test_is_posix_true_3(self): compileman = CompileMan() is_posix_result = compileman.is_posix('darwin') self.assertTrue(is_posix_result)