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'})
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"})
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")
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, { })
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
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"})
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"})
def test_tokenize_single_word(self): (cmd, args, kwargs) = utils.tokenize("vars:") self.assertEqual(cmd, "vars")
def test_tokenize_blank(self): (cmd, args, kwargs) = utils.tokenize("") self.assertEqual(cmd, '') self.assertEqual(args, []) self.assertEqual(kwargs, {})
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'})
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
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"})
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
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'})