Ejemplo 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
Ejemplo 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
Ejemplo 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
Ejemplo n.º 4
0
 def test_no_execute(self):
     runner = Runner(
         ['test.py', 'nohelpnoexecute'],
         commands=[
             'tests.watson.console.support.SampleNoHelpNoExecuteCommand'
         ])
     runner.execute()
Ejemplo 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
Ejemplo 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
Ejemplo 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')
Ejemplo 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')
Ejemplo 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
Ejemplo 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'
Ejemplo 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
Ejemplo n.º 12
0
 def test_execute_command(self):
     runner = Runner(
         ['test.py', 'nonstring'],
         commands=['tests.watson.console.support.SampleNonStringCommand'])
     assert runner()
Ejemplo 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
Ejemplo 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'])
Ejemplo n.º 15
0
 def test_execute_command_with_error(self):
     runner = Runner(
         ['test.py', 'string'],
         commands=['tests.watson.console.support.SampleStringCommand'])
     runner()
Ejemplo 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
Ejemplo 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
Ejemplo 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
Ejemplo 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
Ejemplo n.º 20
0
 def test_no_execute(self):
     with raises(TypeError):
         runner = Runner(['test.py', 'nohelpnoexecute'], commands=[
             'tests.watson.console.support.SampleNoHelpNoExecuteCommand'
         ])
         runner.execute()