예제 #1
0
 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())
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
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)
예제 #6
0
 def test_check_project_types(self):
     compileman = CompileMan()
     project_types = compileman.get_project_types()
     expected_project_types = []
     self.assertListEqual(expected_project_types, project_types)
예제 #7
0
 def test_clean_wrong_type(self):
     compileman = CompileMan()
     with self.assertRaises(Exception):
         compileman.clean(['non_existent'])
예제 #8
0
 def test_cancompile_empty_compilations(self):
     compileman = CompileMan()
     can_compile = compileman.cancompile([])
     self.assertFalse(can_compile)
예제 #9
0
 def test_cancompile_wrong_data(self):
     compileman = CompileMan()
     with self.assertRaises(Exception):
         compileman.cancompile(['not_valid'])
예제 #10
0
 def test_guess_action_compile(self):
     self.empty_folder()
     expected_result = 'compile'
     compileman = CompileMan()
     self.assertEqual(expected_result, compileman.guess_action())
예제 #11
0
 def test_guess_action_doubt_vendor(self):
     self.empty_folder()
     os.makedirs('vendor')
     compileman = CompileMan()
     expected_result = ''
     self.assertEqual(expected_result, compileman.guess_action())
예제 #12
0
 def test_is_vendor_exists_false(self):
     self.empty_folder()
     compileman = CompileMan()
     self.assertFalse(compileman.is_vendor_exists())
예제 #13
0
 def test_is_node_module_exists(self):
     self.empty_folder()
     os.makedirs('node_modules')
     compileman = CompileMan()
     self.assertTrue(compileman.is_node_module_exists())
예제 #14
0
 def test_is_node_module_exists_false(self):
     self.empty_folder()
     compileman = CompileMan()
     self.assertFalse(compileman.is_node_module_exists())
예제 #15
0
 def test_is_posix_true_2(self):
     compileman = CompileMan()
     is_posix_result = compileman.is_posix('linux2')
     self.assertTrue(is_posix_result)
예제 #16
0
 def test_exception_wrong_platform_invalid(self):
     compileman = CompileMan()
     platform = 'unknown_platform'
     with self.assertRaises(Exception):
         compileman.exception_wrong_platform(platform)
예제 #17
0
 def test_universal_subprocess_call_exception(self):
     compileman = CompileMan()
     with self.assertRaises(Exception):
         compile.universal_subprocess_call(['dir'], 'unknown_platform')
예제 #18
0
 def test_is_posix_exception_invalid_name(self):
     compileman = CompileMan()
     with self.assertRaises(Exception):
         compileman.is_posix('not_valid')
예제 #19
0
 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))
예제 #20
0
 def test_is_posix_false(self):
     compileman = CompileMan()
     is_posix_result = compileman.is_posix('win32')
     self.assertFalse(is_posix_result)
예제 #21
0
 def test_is_vendor_exists(self):
     self.empty_folder()
     os.makedirs('vendor')
     compileman = CompileMan()
     self.assertTrue(compileman.is_vendor_exists())
예제 #22
0
 def test_is_posix_true_3(self):
     compileman = CompileMan()
     is_posix_result = compileman.is_posix('darwin')
     self.assertTrue(is_posix_result)