Пример #1
0
 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)
Пример #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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 def test_get_sut_info(self):
     d = tempfile.mkdtemp()
     a = ansible_common.AnsibleCommon({})
     try:
         a.get_sut_info(d)
     finally:
         shutil.rmtree(d)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #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']
     })
Пример #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)
Пример #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())
Пример #11
0
 def test_deploy_dir_set_get(self):
     a = ansible_common.AnsibleCommon({})
     a.deploy_dir = "d"
     self.assertEqual(a.deploy_dir, "d")
Пример #12
0
 def test_deploy_dir_set(self):
     a = ansible_common.AnsibleCommon({})
     a.deploy_dir = ""
Пример #13
0
 def test_deploy_dir(self):
     a = ansible_common.AnsibleCommon({})
     self.assertRaises(ValueError, getattr, a, "deploy_dir")
Пример #14
0
 def test_gen_inventory_dict(self):
     a = ansible_common.AnsibleCommon({})
     a.inventory_dict = {}
     self.assertIsNone(a.gen_inventory_ini_dict())
Пример #15
0
 def test_do_install_no_dir(self):
     a = ansible_common.AnsibleCommon({})
     self.assertRaises(OSError, a.do_install, '', '')
Пример #16
0
 def test_reset(self):
     a = ansible_common.AnsibleCommon({})
     a.reset()
Пример #17
0
 def test__init__(self):
     a = ansible_common.AnsibleCommon({})
Пример #18
0
 def test_get_sut_info_not_exist(self):
     a = ansible_common.AnsibleCommon({})
     try:
         a.get_sut_info('/hello/world')
     except OSError:
         pass
Пример #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)
Пример #20
0
 def test_get_sut_info_not_exist(self):
     a = ansible_common.AnsibleCommon({})
     with self.assertRaises(OSError):
         a.get_sut_info('/hello/world')
Пример #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)