Esempio n. 1
0
 def test_no_cterasdk(self):
     cterasdk_imp_err = "Failed to import"
     self.patch_call(
         "ansible_collections.ctera.ctera.plugins.module_utils.ctera_ansible_module.ctera_common.HAS_CTERASDK",
         new=False)
     self.patch_call(
         "ansible_collections.ctera.ctera.plugins.module_utils.ctera_ansible_module.ctera_common.CTERASDK_IMP_ERR",
         new=cterasdk_imp_err)
     ansible_module = ctera_ansible_module.CteraAnsibleModule(dict())
     self.assertDictEqual(ansible_module.fail_dict,
                          dict(msg=mock.ANY, exception=cterasdk_imp_err))
Esempio n. 2
0
 def _test_ctera_exit(self, has_failed):
     self.ansible_return_value_object_mock.has_failed.return_value = has_failed
     expected_dict = dict(msg='Success')
     self.ansible_return_value_object_mock.as_dict.return_value = expected_dict
     ansible_module = ctera_ansible_module.CteraAnsibleModule(dict())
     ansible_module.ctera_exit()
     if has_failed:
         self.assertDictEqual(ansible_module.exit_dict, {})
         self.assertDictEqual(ansible_module.fail_dict, expected_dict)
     else:
         self.assertDictEqual(ansible_module.exit_dict, expected_dict)
         self.assertDictEqual(ansible_module.fail_dict, {})
Esempio n. 3
0
 def _test_trust_certificate(self, trust):
     ansible_module_mock.trust_certificate = trust
     ctera_ansible_module.CteraAnsibleModule(dict())
     self.assertEqual(ctera_config.http['ssl'],
                      'Trust' if trust else 'Consent')
Esempio n. 4
0
 def test_ctera_return_value(self):
     ansible_module = ctera_ansible_module.CteraAnsibleModule(dict())
     ansible_return_value = ansible_module.ctera_return_value()
     self.assertEqual(self.ansible_return_value_object_mock,
                      ansible_return_value)
Esempio n. 5
0
 def test_ctera_portal_logout():
     ansible_module = ctera_ansible_module.CteraAnsibleModule(dict())
     ansible_module._ctera_host = mock.MagicMock()  # pylint: disable=protected-access
     ansible_module._ctera_host.logout = mock.MagicMock(return_value=None)  # pylint: disable=protected-access
     ansible_module.ctera_logout()
     ansible_module._ctera_host.logout.assert_called_once_with()  # pylint: disable=protected-access