Esempio n. 1
0
 def test_execute_command_with_args_options(self):
     runner = Runner(['test.py', 'runargsoptions', 'test', '-f', 'filename.txt'], commands=[
         'tests.watson.console.support.SampleArgumentsCommand',
         'tests.watson.console.support.SampleArgumentsWithOptionsCommand'
     ])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 2
0
 def test_execute_command_usage(self):
     runner = Runner(commands=[
         'tests.watson.console.support.SampleStringCommand',
         SampleNonStringCommand
     ])
     with raises(SystemExit):
         runner.execute(['test.py', 'nonstring', 'execute', '-h'])  # will print to screen in tests
Esempio n. 3
0
 def test_execute_command_usage(self):
     runner = Runner(['test.py', 'nonstring', '-h'], commands=[
         'tests.watson.console.support.SampleStringCommand',
         SampleNonStringCommand
     ])
     output = runner.execute()  # will print to screen in tests
     assert not output
Esempio n. 4
0
 def test_no_execute(self):
     runner = Runner(
         ['test.py', 'nohelpnoexecute'],
         commands=[
             'tests.watson.console.support.SampleNoHelpNoExecuteCommand'
         ])
     runner.execute()
Esempio n. 5
0
 def test_execute_command_with_args_options(self):
     runner = Runner(['test.py', 'runargsoptions', 'test', '-f', 'filename.txt'], commands=[
         'tests.watson.console.support.SampleArgumentsCommand',
         'tests.watson.console.support.SampleArgumentsWithOptionsCommand'
     ])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 6
0
 def test_execute_command_usage(self):
     runner = Runner(['test.py', 'nonstring', '-h'], commands=[
         'tests.watson.console.support.SampleStringCommand',
         SampleNonStringCommand
     ])
     output = runner.execute()  # will print to screen in tests
     assert not output
Esempio n. 7
0
 def test_add_commands(self):
     runner = Runner()
     assert len(runner.commands) == 0
     runner.add_commands(
         [SampleNonStringCommand,
          'tests.watson.console.support.SampleStringCommand'])
     assert len(runner.commands) == 2
     assert not runner.get_command('test')
Esempio n. 8
0
 def test_add_commands(self):
     runner = Runner()
     assert len(runner.commands) == 0
     runner.add_commands([
         SampleNonStringCommand,
         'tests.watson.console.support.SampleStringCommand'
     ])
     assert len(runner.commands) == 2
     assert not runner.get_command('test')
Esempio n. 9
0
 def __init__(self, config=None, argv=None):
     super(Console, self).__init__(config)
     self.config = dict_deep_update(
         {'commands': find_commands_in_module(DefaultConsoleCommands)},
         self.config)
     self.runner = Runner(argv, commands=self.config.get('commands'))
     self.runner.get_command = self.get_command
Esempio n. 10
0
 def test_create(self):
     runner = Runner(['test.py'], commands=[
         'tests.watson.console.support.SampleStringCommand',
         SampleNonStringCommand
     ])
     assert len(runner.commands) == 2
     assert runner.name == 'test.py'
Esempio n. 11
0
 def test_execute_command_with_args(self):
     runner = Runner(
         ['test.py', 'runargs', 'test', 'test2'],
         commands=['tests.watson.console.support.SampleArgumentsCommand'])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 12
0
 def test_execute_command(self):
     runner = Runner(
         ['test.py', 'nonstring'],
         commands=['tests.watson.console.support.SampleNonStringCommand'])
     assert runner()
Esempio n. 13
0
 def test_execute_command_with_options(self):
     runner = Runner(
         ['test.py', 'runoptions', '-f', 'test'],
         commands=['tests.watson.console.support.SampleOptionsCommand'])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 14
0
 def test_no_execute(self):
     with raises(SystemExit):
         runner = Runner(commands=[
             'tests.watson.console.support.SampleNoHelpNoExecuteCommand'
         ])
         runner.execute(['test.py', 'nohelpnoexecute', 'execute'])
Esempio n. 15
0
 def test_execute_command_with_error(self):
     runner = Runner(
         ['test.py', 'string'],
         commands=['tests.watson.console.support.SampleStringCommand'])
     runner()
Esempio n. 16
0
 def test_execute_command_usage_with_args(self):
     runner = Runner(commands=[
         'tests.watson.console.support.SampleArgumentsCommand'
     ])
     with raises(SystemExit):
         runner.execute(['test.py', 'runargs', 'execute', '-h'])  # will print to screen in tests
Esempio n. 17
0
 def test_execute_command_with_args(self):
     runner = Runner(['test.py', 'runargs', 'test', 'test2'], commands=[
         'tests.watson.console.support.SampleArgumentsCommand'
     ])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 18
0
 def test_execute_command_with_options(self):
     runner = Runner(['test.py', 'runoptions', '-f', 'test'], commands=[
         'tests.watson.console.support.SampleOptionsCommand'
     ])
     output = runner.execute()  # will print to screen in tests
     assert output
Esempio n. 19
0
 def test_execute_command_with_options_invalid(self):
     runner = Runner(commands=[
         'tests.watson.console.support.SampleOptionsCommand'
     ])
     with raises(SystemExit):
         runner.execute(['test.py', 'runoptions', 'execute', '-d'])  # will print to screen in tests
Esempio n. 20
0
 def test_no_execute(self):
     with raises(TypeError):
         runner = Runner(['test.py', 'nohelpnoexecute'], commands=[
             'tests.watson.console.support.SampleNoHelpNoExecuteCommand'
         ])
         runner.execute()