def test_iso_create__success(self, mock_subproc, vspk_patch, module_patch): mock_module = setup_module(module_patch) self.setup_session(vspk_patch) self.setup_license(vspk_patch) self.setup_enterprise(vspk_patch) self.setup_nsg_infra(vspk_patch) self.setup_nsg_template(vspk_patch) self.setup_vsc_infra(vspk_patch) self.setup_nsg_ports(vspk_patch) self.setup_nsg_device(vspk_patch) self.setup_create_iso(vspk_patch) main() self.verify_session(vspk_patch) self.verify_license(vspk_patch) self.verify_enterprise(vspk_patch) self.verify_proxy_user(vspk_patch) self.verify_nsg_infra(vspk_patch) self.verify_nsg_template(vspk_patch) self.verify_vsc_infra(vspk_patch) self.verify_nsg_ports(vspk_patch) self.verify_nsg_device(vspk_patch) self.verify_create_iso(vspk_patch) self.verify_subproc(mock_subproc) mock_module.fail_json.assert_not_called() mock_module.exit_json.assert_called_once_with( changed=True, ansible_facts={"nsgv_already_configured": False})
def test__bad_license(self, module_patch): params = dict(TEST_PARAMS) params["vsd_license_file"] = "invalid_file.bad" mock_module = setup_module(module_patch, params) main() mock_module.fail_json.assert_called_once() args, kwargs = mock_module.fail_json.call_args_list[0] assert "ERROR: Failure reading file: " in kwargs["msg"]
def test__cannot_connect(self, vspk_patch, module_patch): mock_module = setup_module(module_patch) mock_session = MagicMock() vspk_patch.NUVSDSession.return_value = mock_session mock_session.start.side_effect = Exception("Test") main() mock_module.fail_json.assert_called_once() args, kwargs = mock_module.fail_json.call_args_list[0] assert "ERROR: Could not establish connection to VSD" in kwargs["msg"]