Esempio n. 1
0
 def test_config_dump(self, mock_mkdtemp, mock_run, mock_listdir, mock_read,
                      mock_rmtree):
     parser = argparse.ArgumentParser()
     parsed_args = parser.parse_args([])
     dump_dir = mock_mkdtemp.return_value
     mock_listdir.return_value = ["host1.yml", "host2.yml"]
     mock_read.side_effect = [{"var1": "value1"}, {"var2": "value2"}]
     result = ansible.config_dump(parsed_args)
     expected_result = {
         "host1": {
             "var1": "value1"
         },
         "host2": {
             "var2": "value2"
         },
     }
     self.assertEqual(result, expected_result)
     mock_run.assert_called_once_with(parsed_args,
                                      "ansible/dump-config.yml",
                                      extra_vars={
                                          "dump_path": dump_dir,
                                      },
                                      quiet=True,
                                      verbose_level=None,
                                      check=False)
     mock_rmtree.assert_called_once_with(dump_dir)
     mock_listdir.assert_called_once_with(dump_dir)
     mock_read.assert_has_calls([
         mock.call(os.path.join(dump_dir, "host1.yml")),
         mock.call(os.path.join(dump_dir, "host2.yml")),
     ])
Esempio n. 2
0
 def test_config_dump(self, mock_mkdtemp, mock_run, mock_listdir, mock_read,
                      mock_rmtree):
     parser = argparse.ArgumentParser()
     parsed_args = parser.parse_args([])
     dump_dir = "/path/to/dump"
     mock_mkdtemp.return_value = dump_dir
     mock_listdir.return_value = ["host1.yml", "host2.yml"]
     mock_read.side_effect = [{"var1": "value1"}, {"var2": "value2"}]
     result = ansible.config_dump(parsed_args)
     expected_result = {
         "host1": {
             "var1": "value1"
         },
         "host2": {
             "var2": "value2"
         },
     }
     self.assertEqual(result, expected_result)
     dump_config_path = utils.get_data_files_path("ansible",
                                                  "dump-config.yml")
     mock_run.assert_called_once_with(parsed_args,
                                      dump_config_path,
                                      extra_vars={
                                          "dump_path": dump_dir,
                                      },
                                      check_output=True,
                                      tags=None,
                                      verbose_level=None,
                                      check=False,
                                      list_tasks=False,
                                      diff=False)
     mock_rmtree.assert_called_once_with(dump_dir)
     mock_listdir.assert_any_call(dump_dir)
     mock_read.assert_has_calls([
         mock.call(os.path.join(dump_dir, "host1.yml")),
         mock.call(os.path.join(dump_dir, "host2.yml")),
     ])
Esempio n. 3
0
 def run_kayobe_config_dump(self, *args, **kwargs):
     kwargs.update(self._get_verbosity_args())
     return ansible.config_dump(*args, **kwargs)
Esempio n. 4
0
 def run_kayobe_config_dump(self, *args, **kwargs):
     kwargs.update(self._get_verbosity_args())
     return ansible.config_dump(*args, **kwargs)