def test_create_existing(self, svc_authorize_mock, svc_run_command_mock, get_existing_rccg_mock): set_module_args({ 'clustername': 'test_remotecluster', 'domain': 'domain', 'username': '******', 'password': '******', 'name': 'test_name', 'state': 'present', 'copytype': 'metro' }) get_existing_rccg_mock.return_value = { "id": "11", "name": "test_name", "master_cluster_id": "0000020321E04566", "master_cluster_name": "test_remotecluster", "aux_cluster_id": "0000020321E04566", "aux_cluster_name": "test_remotecluster", "primary": "", "state": "empty", "relationship_count": "0", "freeze_time": "", "status": "", "sync": "", "copy_type": "metro", "cycling_mode": "", "cycle_period_seconds": "0" } with pytest.raises(AnsibleExitJson) as exc: obj = IBMSVCRCCG() obj.apply() self.assertFalse(exc.value.args[0]['changed'])
def test_delete_non_existing(self, svc_authorize_mock, svc_run_command_mock, get_existing_rccg_mock): set_module_args({ 'clustername': 'test_remotecluster', 'domain': 'domain', 'username': '******', 'password': '******', 'name': 'test_name', 'state': 'absent', 'copytype': 'metro' }) get_existing_rccg_mock.return_value = {} with pytest.raises(AnsibleExitJson) as exc: obj = IBMSVCRCCG() obj.apply() self.assertFalse(exc.value.args[0]['changed'])
def test_creation(self, svc_authorize_mock, svc_run_command_mock, get_existing_rccg_mock): set_module_args({ 'clustername': 'test_remotecluster', 'domain': 'domain', 'username': '******', 'password': '******', 'name': 'test_name', 'state': 'present' }) get_existing_rccg_mock.return_value = {} svc_run_command_mock.return_value = { 'message': 'RC Consistency Group, id [3], successfully created', 'id': '3' } with pytest.raises(AnsibleExitJson) as exc: obj = IBMSVCRCCG() obj.apply() self.assertTrue(exc.value.args[0]['changed'])