def test_do_install_tmp_dir(self, _, mock_popen, *args):
     mock_popen.return_value.communicate.return_value = "", ""
     mock_popen.return_value.wait.return_value = 0
     d = tempfile.mkdtemp()
     self.addCleanup(self._delete_tmpdir, d)
     a = ansible_common.AnsibleCommon({})
     a.do_install('', d)
Exemple #2
0
 def test__gen_ansible_playbook_file_list(self, _):
     d = tempfile.mkdtemp()
     try:
         a = ansible_common.AnsibleCommon({})
         a._gen_ansible_playbook_file(["a"], d)
     finally:
         os.rmdir(d)
 def test_execute_ansible_check(self, mock_popen, *args):
     mock_popen.return_value.communicate.return_value = "", ""
     mock_popen.return_value.wait.return_value = 0
     d = tempfile.mkdtemp()
     self.addCleanup(self._delete_tmpdir, d)
     a = ansible_common.AnsibleCommon({})
     a.execute_ansible('', d, ansible_check=True, verbose=True)
 def test__gen_ansible_playbook_file_list_multiple(self, mock_open, mock_tmp):
     d = tempfile.mkdtemp()
     try:
         a = ansible_common.AnsibleCommon({})
         a._gen_ansible_playbook_file(["a", "b"], d)
     finally:
         os.rmdir(d)
 def test_get_sut_info(self):
     d = tempfile.mkdtemp()
     a = ansible_common.AnsibleCommon({})
     try:
         a.get_sut_info(d)
     finally:
         shutil.rmtree(d)
 def test_execute_ansible_check(self, mock_open, mock_popen, mock_tmp):
     mock_popen.return_value.communicate.return_value = "", ""
     mock_popen.return_value.wait.return_value = 0
     d = tempfile.mkdtemp()
     try:
         a = ansible_common.AnsibleCommon({})
         a.execute_ansible('', d, ansible_check=True, verbose=True)
     finally:
         os.rmdir(d)
 def test_do_install_tmp_dir(self, mock_open, mock_popen, mock_tmp):
     mock_popen.return_value.communicate.return_value = "", ""
     mock_popen.return_value.wait.return_value = 0
     d = tempfile.mkdtemp()
     try:
         a = ansible_common.AnsibleCommon({})
         a.do_install('', d)
     finally:
         os.rmdir(d)
Exemple #8
0
 def test_gen_inventory_dict(self):
     nodes = [{
         "name": "name", "user": "******", "password": "******",
         "role": "role",
     }]
     a = ansible_common.AnsibleCommon(nodes)
     a.gen_inventory_ini_dict()
     self.assertEqual(a.inventory_dict, {
         'nodes': ['name ansible_ssh_pass=PASS ansible_user=user'],
         'role': ['name']
     })
Exemple #9
0
 def test__gen_ansible_inventory_file(self, _, __):
     nodes = [{
         "name": "name", "user": "******", "password": "******",
         "role": "role",
     }]
     d = tempfile.mkdtemp()
     try:
         a = ansible_common.AnsibleCommon(nodes)
         a.gen_inventory_ini_dict()
         inv_context = a._gen_ansible_inventory_file(d)
         with inv_context:
             c = StringIO()
             inv_context.write_func(c)
             self.assertIn("ansible_ssh_pass=PASS", c.getvalue())
     finally:
         os.rmdir(d)
Exemple #10
0
 def test__gen_ansible_inventory_file(self, *args):
     nodes = [{
         "name": "name",
         "user": "******",
         "password": "******",
         "role": "role",
     }]
     d = tempfile.mkdtemp()
     self.addCleanup(self._delete_tmpdir, d)
     a = ansible_common.AnsibleCommon(nodes)
     a.gen_inventory_ini_dict()
     inv_context = a._gen_ansible_inventory_file(d)
     with inv_context:
         c = moves.StringIO()
         inv_context.write_func(c)
         self.assertIn("ansible_ssh_pass=PASS", c.getvalue())
 def test_deploy_dir_set_get(self):
     a = ansible_common.AnsibleCommon({})
     a.deploy_dir = "d"
     self.assertEqual(a.deploy_dir, "d")
 def test_deploy_dir_set(self):
     a = ansible_common.AnsibleCommon({})
     a.deploy_dir = ""
 def test_deploy_dir(self):
     a = ansible_common.AnsibleCommon({})
     self.assertRaises(ValueError, getattr, a, "deploy_dir")
 def test_gen_inventory_dict(self):
     a = ansible_common.AnsibleCommon({})
     a.inventory_dict = {}
     self.assertIsNone(a.gen_inventory_ini_dict())
 def test_do_install_no_dir(self):
     a = ansible_common.AnsibleCommon({})
     self.assertRaises(OSError, a.do_install, '', '')
 def test_reset(self):
     a = ansible_common.AnsibleCommon({})
     a.reset()
 def test__init__(self):
     a = ansible_common.AnsibleCommon({})
 def test_get_sut_info_not_exist(self):
     a = ansible_common.AnsibleCommon({})
     try:
         a.get_sut_info('/hello/world')
     except OSError:
         pass
Exemple #19
0
 def test__gen_ansible_playbook_file_list_multiple(self, *args):
     d = tempfile.mkdtemp()
     self.addCleanup(self._delete_tmpdir, d)
     a = ansible_common.AnsibleCommon({})
     a._gen_ansible_playbook_file(["a", "b"], d)
Exemple #20
0
 def test_get_sut_info_not_exist(self):
     a = ansible_common.AnsibleCommon({})
     with self.assertRaises(OSError):
         a.get_sut_info('/hello/world')
Exemple #21
0
 def test_get_sut_info(self):
     d = tempfile.mkdtemp()
     a = ansible_common.AnsibleCommon({})
     self.addCleanup(self._delete_tmpdir, d)
     with mock.patch.object(a, '_exec_get_sut_info_cmd'):
         a.get_sut_info(d)