Exemple #1
0
    def test_extra_vars_as_a_list(self):
        args = playbooks.get_command_args({
            "extra-vars": ["key1=var1", "key2=var2"]})

        expected = json.loads('{"key1": "var1", "key2": "var2"}')
        actual = json.loads(args["--extra-vars"])
        self.assertEqual(expected, actual)
Exemple #2
0
 def test_dashes(self):
     args = playbooks.get_command_args({
         "key1": "val1",
         "--key2": "val2"})
     self.assertEqual("val1", args["--key1"])
     self.assertEqual("val2", args["--key2"])
     self.assertNotIn("key1", args)
Exemple #3
0
    def test_verbose_command(self):
        args = playbooks.get_command_args({"verbose": "3"})
        cmdline = playbooks.build_command_line('testcommand', 'testplaybook',
                                               args)

        num = cmdline.count('--verbose')
        self.assertTrue(num == 3)
Exemple #4
0
 def test_vault_pass_deprecated_empty_0(self):
     args = playbooks.get_command_args({"encryptionKey": ""})
     self.assertNotIn('--vault-password-file', args)
Exemple #5
0
 def test_vault_pass_deprecated_1(self):
     args = playbooks.get_command_args({"encryption-key": "testabce"})
     self.assertIn('--vault-password-file', args)
Exemple #6
0
 def test_no_vault_pass_extra_vars_as_list(self):
     list = ["encrypt="]
     args = playbooks.get_command_args({"extra-vars": list})
     self.assertNotIn('--vault-password-file', args)
Exemple #7
0
 def test_no_vault_pass_extra_vars_as_dict(self):
     dict = {"encrypt": ""}
     args = playbooks.get_command_args({"extra-vars": dict})
     self.assertNotIn('--vault-password-file', args)
Exemple #8
0
 def test_override_inventory(self):
     args = playbooks.get_command_args({'--inventory': 'foo'})
     self.assertEqual("foo", args['--inventory'])
Exemple #9
0
 def test_force_omit_inventory(self):
     args = playbooks.get_command_args({'inventory': None})
     self.assertNotIn('--inventory', args)
Exemple #10
0
 def test_pre_inventory(self):
     args = playbooks.get_command_args({"foo": "bar"},
                                       CONF.paths.pre_playbooks_dir)
     self.assertEqual("hosts/localhost", args['--inventory'])
Exemple #11
0
 def test_default_inventory(self):
     args = playbooks.get_command_args({"foo": "bar"})
     self.assertEqual("hosts/verb_hosts", args['--inventory'])
Exemple #12
0
 def test_extra_vars_as_a_dict(self):
     d = {"key1": "var1", "key2": "var2"}
     args = playbooks.get_command_args({"extra-vars": d})
     actual = json.loads(args["--extra-vars"])
     self.assertEqual(d, actual)
Exemple #13
0
 def test_has_verbose(self):
     args = playbooks.get_command_args({"verbose": "4"})
     self.assertEqual("4", args['--verbose'])
Exemple #14
0
 def test_has_no_verbose(self):
     args = playbooks.get_command_args({"verbose": "0"})
     self.assertNotIn("--verbose", args)