def test_delete_fccg_successfully(self, svc_authorize_mock, fccg_delete_mock, get_existing_fccg_mock): set_module_args({ 'clustername': 'clustername', 'domain': 'domain', 'state': 'absent', 'username': '******', 'password': '******', 'name': 'test_delete_fccg_successfully', }) fccg_ret = [{ "id": "1", "name": "fccstgrp0", "status": "empty", "start_time": "", "owner_id": "", "owner_name": "" }] get_existing_fccg_mock.return_value = fccg_ret host_deleted = IBMSVCFCCG() with pytest.raises(AnsibleExitJson) as exc: host_deleted.apply() self.assertTrue(exc.value.args[0]['changed']) get_existing_fccg_mock.assert_called_with()
def test_fccg_create_get_existing_fccg_called(self, svc_authorize_mock, get_existing_fccg_mock): set_module_args({ 'clustername': 'clustername', 'domain': 'domain', 'state': 'present', 'username': '******', 'password': '******', 'name': 'test_fccg_create_get_existing_fccg_called', }) fccg_created = IBMSVCFCCG() with pytest.raises(AnsibleFailJson) as exc: fccg_created.apply() get_existing_fccg_mock.assert_called_with()
def test_delete_fccg_but_fccg_not_existed(self, svc_authorize_mock, get_existing_fccg_mock): set_module_args({ 'clustername': 'clustername', 'domain': 'domain', 'state': 'absent', 'username': '******', 'password': '******', 'name': 'test_delete_fccg_but_fccg_not_existed', }) get_existing_fccg_mock.return_value = [] host_deleted = IBMSVCFCCG() with pytest.raises(AnsibleExitJson) as exc: host_deleted.apply() self.assertFalse(exc.value.args[0]['changed']) get_existing_fccg_mock.assert_called_with()
def test_create_fccg_successfully(self, svc_authorize_mock, fccg_create_mock, get_existing_fccg_mock): set_module_args({ 'clustername': 'clustername', 'domain': 'domain', 'state': 'present', 'username': '******', 'password': '******', 'name': 'test_create_fccg_successfully', }) fccg = { u'message': u'FlashCopy Consistency Group, id [35], ' u'successfully created', u'id': u'35' } fccg_create_mock.return_value = fccg get_existing_fccg_mock.return_value = [] fccg_created = IBMSVCFCCG() with pytest.raises(AnsibleExitJson) as exc: fccg_created.apply() self.assertTrue(exc.value.args[0]['changed']) get_existing_fccg_mock.assert_called_with()