def test_kwargs_json_empty_dict(self): parsed_args = {'kind': 'noop', 'uri': None, 'kwargs': [('empty', 'json:{}')]} runnable = nrunner.runnable_from_args(parsed_args) self.assertEqual(runnable.kind, 'noop') self.assertIsNone(runnable.uri) self.assertEqual(runnable.kwargs.get('empty'), {})
def test_exec_args(self): parsed_args = {'kind': 'exec', 'uri': '/path/to/executable', 'arg': ['-a', '-b', '-c']} runnable = nrunner.runnable_from_args(parsed_args) self.assertEqual(runnable.kind, 'exec') self.assertEqual(runnable.uri, '/path/to/executable') self.assertEqual(runnable.args, ('-a', '-b', '-c')) self.assertEqual(runnable.kwargs, {})
def test_exec_args_kwargs(self): parsed_args = {'kind': 'exec', 'uri': '/path/to/executable', 'arg': ['-a', '-b', '-c'], 'kwargs': [('DEBUG', '1'), ('LC_ALL', 'C')]} runnable = nrunner.runnable_from_args(parsed_args) self.assertEqual(runnable.kind, 'exec') self.assertEqual(runnable.uri, '/path/to/executable') self.assertEqual(runnable.args, ('-a', '-b', '-c')) self.assertEqual(runnable.kwargs.get('DEBUG'), '1') self.assertEqual(runnable.kwargs.get('LC_ALL'), 'C')
def test_kwargs_json_dict(self): parsed_args = { 'kind': 'noop', 'uri': None, 'kwargs': [('tags', 'json:{"arch": ["x86_64", "ppc64"]}'), ('hi', 'json:"hello"')] } runnable = nrunner.runnable_from_args(parsed_args) self.assertEqual(runnable.kind, 'noop') self.assertIsNone(runnable.uri) self.assertEqual(runnable.kwargs.get('hi'), 'hello') self.assertEqual(runnable.tags.get('arch'), ["x86_64", "ppc64"])
def subcommand_task_run(args, echo=print): runnable = runnable_from_args(args) task = Task(args.get('identifier'), runnable, args.get('status_uri', [])) task.capables = RUNNABLE_KIND_CAPABLE task_run(task, echo)
def subcommand_runnable_run(args, echo=print): runnable = runnable_from_args(args) runner = runner_from_runnable(runnable, RUNNABLE_KIND_CAPABLE) for status in runner.run(): echo(status)
def test_noop(self): parsed_args = {'kind': 'noop', 'uri': None} runnable = nrunner.runnable_from_args(parsed_args) self.assertEqual(runnable.kind, 'noop') self.assertIsNone(runnable.uri)