def test_kwargs_json_empty_dict(self):
     parsed_args = {
         'kind': 'noop',
         'uri': None,
         'kwargs': [('empty', 'json:{}')]
     }
     runnable = 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-test',
         'uri': '/path/to/executable',
         'arg': ['-a', '-b', '-c']
     }
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, 'exec-test')
     self.assertEqual(runnable.uri, '/path/to/executable')
     self.assertEqual(runnable.args, ('-a', '-b', '-c'))
     self.assertEqual(runnable.kwargs, {})
Example #3
0
 def test_exec_args(self):
     parsed_args = {
         "kind": "exec-test",
         "uri": "/path/to/executable",
         "arg": ["-a", "-b", "-c"],
     }
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, "exec-test")
     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-test',
         'uri': '/path/to/executable',
         'arg': ['-a', '-b', '-c'],
         'kwargs': [('DEBUG', '1'), ('LC_ALL', 'C')]
     }
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, 'exec-test')
     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')
Example #5
0
 def test_exec_args_kwargs(self):
     parsed_args = {
         "kind": "exec-test",
         "uri": "/path/to/executable",
         "arg": ["-a", "-b", "-c"],
         "kwargs": [("DEBUG", "1"), ("LC_ALL", "C")],
     }
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, "exec-test")
     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")
Example #6
0
    def command_runnable_run(self, args):
        """
        Runs a runnable definition from arguments

        This defines a Runnable instance purely from the command line
        arguments, then selects a suitable Runner, and runs it.

        :param args: parsed command line arguments turned into a dictionary
        :type args: dict
        """
        runnable = Runnable.from_args(args)
        runner = self.get_runner_from_runnable(runnable)
        for status in runner.run(runnable):
            self.echo(status)
 def test_kwargs_json_dict(self):
     parsed_args = {
         'kind':
         'noop',
         'uri':
         None,
         'kwargs': [('tags', 'json:{"arch": ["x86_64", "ppc64"]}'),
                    ('hi', 'json:"hello"')]
     }
     runnable = 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"])
Example #8
0
 def test_kwargs_json_dict(self):
     parsed_args = {
         "kind": "noop",
         "uri": None,
         "kwargs": [
             ("tags", 'json:{"arch": ["x86_64", "ppc64"]}'),
             ("hi", 'json:"hello"'),
         ],
     }
     runnable = 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"])
Example #9
0
    def command_task_run(self, args):
        """
        Runs a task from arguments

        :param args: parsed command line arguments turned into a dictionary
        :type args: dict
        """
        runnable = Runnable.from_args(args)
        task = Task(runnable,
                    args.get('identifier'),
                    args.get('status_uri', []),
                    category=args.get('category', TASK_DEFAULT_CATEGORY),
                    job_id=args.get('job_id'))
        for status in task.run():
            self.echo(status)
Example #10
0
 def test_noop(self):
     parsed_args = {'kind': 'noop', 'uri': None}
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, 'noop')
     self.assertIsNone(runnable.uri)
Example #11
0
 def test_kwargs_json_empty_dict(self):
     parsed_args = {"kind": "noop", "uri": None, "kwargs": [("empty", "json:{}")]}
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, "noop")
     self.assertIsNone(runnable.uri)
     self.assertEqual(runnable.kwargs.get("empty"), {})
Example #12
0
 def test_noop(self):
     parsed_args = {"kind": "noop", "uri": None}
     runnable = Runnable.from_args(parsed_args)
     self.assertEqual(runnable.kind, "noop")
     self.assertIsNone(runnable.uri)