def test_rccg_probe_failure_when_invalid_input(self, svc_authorize_mock, svc_obj_info_mock): set_module_args({ 'clustername': 'test_remotecluster', 'domain': 'domain', 'username': '******', 'password': '******', 'name': 'test_name', 'state': 'present', 'copytype': 'invalid_input' }) arg_data = { "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": "global", "cycling_mode": "", "cycle_period_seconds": "0" } with pytest.raises(AnsibleFailJson) as exc: obj = IBMSVCRCCG() obj.rccg_probe(arg_data) self.assertTrue(exc.value.args[0]["failed"])
def test_rccg_probe(self, svc_authorize_mock, svc_obj_info_mock): set_module_args({ 'clustername': 'test_remotecluster', 'domain': 'domain', 'username': '******', 'password': '******', 'name': 'test_name', 'state': 'present', 'copytype': 'metro', }) arg_data = { "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": "global", "cycling_mode": "", "cycle_period_seconds": "0" } obj = IBMSVCRCCG() return_data = obj.rccg_probe(arg_data) self.assertIn('metro', return_data[0]) self.assertTrue(return_data[0]["metro"])