Esempio n. 1
0
 def test_tokenize_command_with_args(self):
     cmd, args, kwargs = utils.tokenize("action: command chdir=wxy creates=zyx tar xzf zyx.tgz")
     self.assertEqual(cmd, "command")
     self.assertEqual(args[0], "tar")
     self.assertEqual(args[1], "xzf")
     self.assertEqual(args[2], "zyx.tgz")
     self.assertEqual(kwargs, {'chdir': 'wxy', 'creates': 'zyx'})
Esempio n. 2
0
 def test_tokenize_command_with_args(self):
     cmd, args, kwargs = utils.tokenize("action: command chdir=wxy creates=zyx tar xzf zyx.tgz")
     self.assertEqual(cmd, "command")
     self.assertEqual(args[0], "tar")
     self.assertEqual(args[1], "xzf")
     self.assertEqual(args[2], "zyx.tgz")
     self.assertEqual(kwargs, {"chdir": "wxy", "creates": "zyx"})
Esempio n. 3
0
 def test_tokenize_more_than_one_arg(self):
     (cmd, args, kwargs) = utils.tokenize("action: whatever bobbins x=y z=x c=3")
     self.assertEqual(cmd, "whatever")
     self.assertEqual(args[0], "bobbins")
     self.assertEqual(args[1], "x=y")
     self.assertEqual(args[2], "z=x")
     self.assertEqual(args[3], "c=3")
Esempio n. 4
0
 def test_tokenize_command_with_nested_jinja(self):
     (cmd, args, kwargs) = utils.tokenize("action: command tar xzf '{{ item }}'")
     self.assertEquals(cmd, "command")
     self.assertEquals(args[0], "tar")
     self.assertEquals(args[1], "xzf")
     self.assertEquals(args[2], "'{{ item }}'")
     self.assertEquals(kwargs, { })
Esempio n. 5
0
def test_tokenize(
    string: str,
    expected_cmd: str,
    expected_args: Sequence[str],
    expected_kwargs: Dict[str, Any],
) -> None:
    """Test that tokenize works for different input types."""
    (cmd, args, kwargs) = utils.tokenize(string)
    assert cmd == expected_cmd
    assert args == expected_args
    assert kwargs == expected_kwargs
Esempio n. 6
0
 def test_tokenize_strips_action(self):
     (cmd, args, kwargs) = utils.tokenize("action: hello a=1")
     self.assertEqual(cmd, "hello")
     self.assertEqual(args, [])
     self.assertEqual(kwargs, {"a": "1"})
Esempio n. 7
0
 def test_tokenize_string_module_and_arg(self):
     (cmd, args, kwargs) = utils.tokenize("hello: a=1")
     self.assertEqual(cmd, "hello")
     self.assertEqual(kwargs, {"a": "1"})
Esempio n. 8
0
 def test_tokenize_single_word(self):
     (cmd, args, kwargs) = utils.tokenize("vars:")
     self.assertEqual(cmd, "vars")
Esempio n. 9
0
 def test_tokenize_blank(self):
     (cmd, args, kwargs) = utils.tokenize("")
     self.assertEqual(cmd, '')
     self.assertEqual(args, [])
     self.assertEqual(kwargs, {})
Esempio n. 10
0
 def test_tokenize_more_than_one_arg(self):
     (cmd, args, kwargs) = utils.tokenize("action: whatever bobbins x=y z=x c=3")
     self.assertEquals(cmd, "whatever")
     self.assertEquals(args[0], "bobbins")
     self.assertEquals(kwargs, {'x': 'y', 'z': 'x', 'c': '3'})
Esempio n. 11
0
def test_tokenize(string, expected_cmd, expected_args, expected_kwargs):
    """Test that tokenize works for different input types."""
    (cmd, args, kwargs) = utils.tokenize(string)
    assert cmd == expected_cmd
    assert args == expected_args
    assert kwargs == expected_kwargs
Esempio n. 12
0
 def test_tokenize_more_than_one_arg(self):
     (cmd, args, kwargs) = utils.tokenize("action: whatever bobbins x=y z=x c=3")
     self.assertEqual(cmd, "whatever")
     self.assertEqual(args[0], "bobbins")
     self.assertEqual(kwargs, {"x": "y", "z": "x", "c": "3"})
Esempio n. 13
0
def test_tokenize(string, expected_cmd, expected_args, expected_kwargs):
    (cmd, args, kwargs) = utils.tokenize(string)
    assert cmd == expected_cmd
    assert args == expected_args
    assert kwargs == expected_kwargs
Esempio n. 14
0
 def test_tokenize_more_than_one_arg(self):
     (cmd, args, kwargs) = utils.tokenize("action: whatever bobbins x=y z=x c=3")
     self.assertEqual(cmd, "whatever")
     self.assertEqual(args[0], "bobbins")
     self.assertEqual(kwargs, {'x': 'y', 'z': 'x', 'c': '3'})