class Test_test_command_line(unittest.TestCase):
    # Mock the print call in CommandLine()
    @patch('command_line.print', create=True)
    # Note added , print_ to mock print()
    def test_command_line_no_jobs_file_specified(self, print_):
        sys.argv = ['ScriptedJsonEditor']
        with patch('builtins.input', return_value=''):
            self.CLo = CommandLine()
        jobsFile = self.CLo.get_jobs_file()
        assert jobsFile is None, jobsFile

    '''
    No job file in command line now calls the GUI
    @patch('command_line.print', create=True)                   # Mock the print call in CommandLine()
    def test_command_line_jobs_file_entered(self, print_):      # Note added , print_ to mock print()
        """ Test console entry of the job file name """
        sys.argv = ['ScriptedJsonEditor']
        with patch('builtins.input', return_value='JsonEditorJobs.json'):
          self.CLo = CommandLine()
        jobsFile = self.CLo.get_jobs_file()
        assert jobsFile == 'JsonEditorJobs.json', jobsFile
    '''

    def test_command_line(self):
        sys.argv = ['ScriptedJsonEditor', 'JsonEditorJobs.json']
        self.CLo = CommandLine()
        jobsFile = self.CLo.get_jobs_file()
        assert jobsFile == 'JsonEditorJobs.json', jobsFile
Пример #2
0
def main(versionStr=''):
    """ Main """
    _clo = CommandLine(versionStr)
    jobs_file_name = _clo.get_jobs_file()
    playerID = _clo.get_playerID()
    rF2root = _clo.get_rF2root()
    if jobs_file_name is None:
        import GUI  # if imported "normally" there is a deadly embrace
        # when GUI imports this file.
        # No jobs file in command line
        GUI.Main(playerID, rF2root, goCommand=True)
        return 0, ''
    return execute_job_file(playerID, rF2root, jobs_file_name)