| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
"""Unit Tests for Info V2 module on PowerFlex""" |
| 6 |
|
| 7 |
from __future__ import (absolute_import, division, print_function) |
| 8 |
|
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
import pytest |
| 12 |
|
| 13 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.libraries import initial_mock |
| 14 |
from mock.mock import MagicMock |
| 15 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_info_api_v2 import MockInfoApi |
| 16 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_api_exception \ |
| 17 |
import MockApiException |
| 18 |
from ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell \ |
| 19 |
import utils |
| 20 |
from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_fail_json \ |
| 21 |
import FailJsonException, fail_json |
| 22 |
|
| 23 |
utils.get_logger = MagicMock() |
| 24 |
utils.get_powerflex_gateway_host_connection = MagicMock() |
| 25 |
utils.PowerFlexClient = MagicMock() |
| 26 |
utils.filter_response = MagicMock() |
| 27 |
|
| 28 |
from ansible.module_utils import basic |
| 29 |
basic.AnsibleModule = MagicMock() |
| 30 |
from ansible_collections.dellemc.powerflex.plugins.modules.info_v2 import PowerFlexInfo, get_powerflex_info_parameters |
| 31 |
INVALID_SORT_MSG = 'messageCode=PARSE002 displayMessage=An invalid column name: invalid is entered in the sort list' |
| 32 |
|
| 33 |
|
| 34 |
class TestPowerflexInfo(): |
| 35 |
|
| 36 |
get_module_args = MockInfoApi.INFO_COMMON_ARGS |
| 37 |
|
| 38 |
@pytest.fixture |
| 39 |
def info_module_mock(self, mocker): |
| 40 |
mocker.patch( |
| 41 |
MockInfoApi.MODULE_UTILS_PATH + '.PowerFlexClient', |
| 42 |
new=MockApiException) |
| 43 |
utils.is_version_less = MagicMock(return_value=False) |
| 44 |
utils.is_version_ge_or_eq = MagicMock(return_value=True) |
| 45 |
info_module_mock = PowerFlexInfo() |
| 46 |
info_module_mock.module.argument_spec = get_powerflex_info_parameters() |
| 47 |
info_module_mock.module.check_mode = False |
| 48 |
info_module_mock.powerflex_conn.system.get = MagicMock( |
| 49 |
return_value=MockInfoApi.INFO_ARRAY_DETAILS |
| 50 |
) |
| 51 |
info_module_mock.module.fail_json = fail_json |
| 52 |
return info_module_mock |
| 53 |
|
| 54 |
def capture_fail_json_call(self, error_msg, info_module_mock): |
| 55 |
try: |
| 56 |
info_module_mock.perform_module_operation() |
| 57 |
except FailJsonException as fj_object: |
| 58 |
assert len(error_msg) > 0 and error_msg in fj_object.message |
| 59 |
|
| 60 |
def test_get_volume_details(self, info_module_mock): |
| 61 |
self.get_module_args.update({ |
| 62 |
"gather_subset": ['vol'] |
| 63 |
}) |
| 64 |
info_module_mock.module.params = self.get_module_args |
| 65 |
volume_resp = MockInfoApi.INFO_VOLUME_GET_LIST |
| 66 |
info_module_mock.powerflex_conn.volume.get = MagicMock( |
| 67 |
return_value=volume_resp |
| 68 |
) |
| 69 |
volume_stat_resp = MockInfoApi.INFO_VOLUME_STATISTICS |
| 70 |
info_module_mock.powerflex_conn.utility.query_metrics = MagicMock( |
| 71 |
return_value=volume_stat_resp |
| 72 |
) |
| 73 |
info_module_mock.perform_module_operation() |
| 74 |
info_module_mock.powerflex_conn.volume.get.assert_called() |
| 75 |
info_module_mock.powerflex_conn.utility.query_metrics.assert_called() |
| 76 |
|
| 77 |
def test_get_volume_details_filter(self, info_module_mock): |
| 78 |
self.get_module_args.update({ |
| 79 |
"gather_subset": ['vol'], |
| 80 |
"filters": [{ |
| 81 |
"filter_key": "storagePoolId", |
| 82 |
"filter_operator": "equal", |
| 83 |
"filter_value": "test_pool_id_1" |
| 84 |
}] |
| 85 |
}) |
| 86 |
info_module_mock.module.params = self.get_module_args |
| 87 |
vol_resp = MockInfoApi.INFO_VOLUME_GET_LIST |
| 88 |
info_module_mock.powerflex_conn.volume.get = MagicMock( |
| 89 |
return_value=vol_resp |
| 90 |
) |
| 91 |
info_module_mock.perform_module_operation() |
| 92 |
info_module_mock.powerflex_conn.volume.get.assert_called() |
| 93 |
|
| 94 |
def test_get_volume_details_with_exception(self, info_module_mock): |
| 95 |
self.get_module_args.update({ |
| 96 |
"gather_subset": ['vol'] |
| 97 |
}) |
| 98 |
info_module_mock.module.params = self.get_module_args |
| 99 |
volume_resp = MockInfoApi.INFO_VOLUME_GET_LIST |
| 100 |
info_module_mock.powerflex_conn.volume.get = MagicMock( |
| 101 |
return_value=volume_resp |
| 102 |
) |
| 103 |
info_module_mock.powerflex_conn.utility.query_metrics = MagicMock( |
| 104 |
side_effect=MockApiException |
| 105 |
) |
| 106 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 107 |
'volume_get_details'), info_module_mock) |
| 108 |
|
| 109 |
def test_get_sp_details(self, info_module_mock): |
| 110 |
self.get_module_args.update({ |
| 111 |
"gather_subset": ['storage_pool'] |
| 112 |
}) |
| 113 |
info_module_mock.module.params = self.get_module_args |
| 114 |
sp_resp = MockInfoApi.INFO_STORAGE_POOL_GET_LIST |
| 115 |
info_module_mock.powerflex_conn.storage_pool.get = MagicMock( |
| 116 |
return_value=sp_resp |
| 117 |
) |
| 118 |
sp_stat_resp = MockInfoApi.INFO_STORAGE_POOL_STATISTICS |
| 119 |
info_module_mock.powerflex_conn.utility.query_metrics = MagicMock( |
| 120 |
return_value=sp_stat_resp |
| 121 |
) |
| 122 |
info_module_mock.perform_module_operation() |
| 123 |
info_module_mock.powerflex_conn.storage_pool.get.assert_called() |
| 124 |
info_module_mock.powerflex_conn.utility.query_metrics.assert_called() |
| 125 |
|
| 126 |
def test_get_sp_details_filter(self, info_module_mock): |
| 127 |
self.get_module_args.update({ |
| 128 |
"gather_subset": ['storage_pool'], |
| 129 |
"filters": [{ |
| 130 |
"filter_key": "id", |
| 131 |
"filter_operator": "equal", |
| 132 |
"filter_value": "test_pool_id_1" |
| 133 |
}] |
| 134 |
}) |
| 135 |
info_module_mock.module.params = self.get_module_args |
| 136 |
storage_pool_resp = MockInfoApi.INFO_STORAGE_POOL_GET_LIST |
| 137 |
info_module_mock.powerflex_conn.storage_pool.get = MagicMock( |
| 138 |
return_value=storage_pool_resp |
| 139 |
) |
| 140 |
info_module_mock.perform_module_operation() |
| 141 |
info_module_mock.powerflex_conn.storage_pool.get.assert_called() |
| 142 |
|
| 143 |
def test_get_sp_details_with_exception(self, info_module_mock): |
| 144 |
self.get_module_args.update({ |
| 145 |
"gather_subset": ['storage_pool'] |
| 146 |
}) |
| 147 |
info_module_mock.module.params = self.get_module_args |
| 148 |
sp_resp = MockInfoApi.INFO_STORAGE_POOL_GET_LIST |
| 149 |
info_module_mock.powerflex_conn.storage_pool.get = MagicMock( |
| 150 |
return_value=sp_resp |
| 151 |
) |
| 152 |
info_module_mock.powerflex_conn.utility.query_metrics = MagicMock( |
| 153 |
side_effect=MockApiException |
| 154 |
) |
| 155 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 156 |
'sp_get_details'), info_module_mock) |
| 157 |
|
| 158 |
def test_get_snapshot_policy_details(self, info_module_mock): |
| 159 |
self.get_module_args.update({ |
| 160 |
"gather_subset": ['snapshot_policy'] |
| 161 |
}) |
| 162 |
info_module_mock.module.params = self.get_module_args |
| 163 |
snapshot_policy_resp = MockInfoApi.INFO_SNAPSHOT_POLICY_GET_LIST |
| 164 |
info_module_mock.powerflex_conn.snapshot_policy.get = MagicMock( |
| 165 |
return_value=snapshot_policy_resp |
| 166 |
) |
| 167 |
info_module_mock.perform_module_operation() |
| 168 |
info_module_mock.powerflex_conn.snapshot_policy.get.assert_called() |
| 169 |
|
| 170 |
def test_get_sdc_details(self, info_module_mock): |
| 171 |
self.get_module_args.update({ |
| 172 |
"gather_subset": ['sdc'] |
| 173 |
}) |
| 174 |
info_module_mock.module.params = self.get_module_args |
| 175 |
sdc_resp = MockInfoApi.INFO_SDC_FILTER_LIST |
| 176 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 177 |
return_value=sdc_resp |
| 178 |
) |
| 179 |
info_module_mock.perform_module_operation() |
| 180 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 181 |
|
| 182 |
def test_get_sdc_details_filter(self, info_module_mock): |
| 183 |
self.get_module_args.update({ |
| 184 |
"gather_subset": ['sdc'], |
| 185 |
"filters": [{ |
| 186 |
"filter_key": "name", |
| 187 |
"filter_operator": "equal", |
| 188 |
"filter_value": "sdc_1" |
| 189 |
}] |
| 190 |
}) |
| 191 |
info_module_mock.module.params = self.get_module_args |
| 192 |
sdc_resp = MockInfoApi.INFO_SDC_FILTER_LIST |
| 193 |
info_module_mock.powerflex_conn.sdc.create = MagicMock( |
| 194 |
return_value=sdc_resp |
| 195 |
) |
| 196 |
info_module_mock.perform_module_operation() |
| 197 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 198 |
|
| 199 |
def test_get_sdc_details_exception(self, info_module_mock): |
| 200 |
self.get_module_args.update({ |
| 201 |
"gather_subset": ['sdc'] |
| 202 |
}) |
| 203 |
info_module_mock.module.params = self.get_module_args |
| 204 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 205 |
side_effect=MockApiException |
| 206 |
) |
| 207 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 208 |
'sdc_get_details'), info_module_mock) |
| 209 |
|
| 210 |
def test_get_pd_details(self, info_module_mock): |
| 211 |
self.get_module_args.update({ |
| 212 |
"gather_subset": ['protection_domain'] |
| 213 |
}) |
| 214 |
info_module_mock.module.params = self.get_module_args |
| 215 |
pd_resp = MockInfoApi.INFO_GET_PD_LIST |
| 216 |
info_module_mock.powerflex_conn.protection_domain.get = MagicMock( |
| 217 |
return_value=pd_resp |
| 218 |
) |
| 219 |
info_module_mock.perform_module_operation() |
| 220 |
info_module_mock.powerflex_conn.protection_domain.get.assert_called() |
| 221 |
|
| 222 |
def test_get_pd_filter_details(self, info_module_mock): |
| 223 |
self.get_module_args.update({ |
| 224 |
"gather_subset": ['protection_domain'], |
| 225 |
"filters": [{ |
| 226 |
"filter_key": "name", |
| 227 |
"filter_operator": "equal", |
| 228 |
"filter_value": "domain1", |
| 229 |
}] |
| 230 |
}) |
| 231 |
info_module_mock.module.params = self.get_module_args |
| 232 |
pd_resp = MockInfoApi.INFO_GET_PD_LIST |
| 233 |
info_module_mock.powerflex_conn.protection_domain.get = MagicMock( |
| 234 |
return_value=pd_resp |
| 235 |
) |
| 236 |
info_module_mock.perform_module_operation() |
| 237 |
info_module_mock.powerflex_conn.protection_domain.get.assert_called() |
| 238 |
|
| 239 |
def test_get_pd_details_exception(self, info_module_mock): |
| 240 |
self.get_module_args.update({ |
| 241 |
"gather_subset": ['protection_domain'] |
| 242 |
}) |
| 243 |
info_module_mock.module.params = self.get_module_args |
| 244 |
info_module_mock.powerflex_conn.protection_domain.get = MagicMock( |
| 245 |
side_effect=MockApiException |
| 246 |
) |
| 247 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 248 |
'pd_get_details'), info_module_mock) |
| 249 |
|
| 250 |
def test_get_device_details(self, info_module_mock): |
| 251 |
self.get_module_args.update({ |
| 252 |
"gather_subset": ['device'] |
| 253 |
}) |
| 254 |
info_module_mock.module.params = self.get_module_args |
| 255 |
device_resp = MockInfoApi.INFO_GET_DEVICE_LIST |
| 256 |
info_module_mock.powerflex_conn.device.get = MagicMock( |
| 257 |
return_value=device_resp |
| 258 |
) |
| 259 |
info_module_mock.perform_module_operation() |
| 260 |
info_module_mock.powerflex_conn.device.get.assert_called() |
| 261 |
|
| 262 |
def test_get_device_filter_details(self, info_module_mock): |
| 263 |
self.get_module_args.update({ |
| 264 |
"gather_subset": ['device'], |
| 265 |
"filters": [{ |
| 266 |
"filter_key": "name", |
| 267 |
"filter_operator": "equal", |
| 268 |
"filter_value": "device230", |
| 269 |
}] |
| 270 |
}) |
| 271 |
info_module_mock.module.params = self.get_module_args |
| 272 |
device_resp = MockInfoApi.INFO_GET_DEVICE_LIST |
| 273 |
info_module_mock.powerflex_conn.device.get = MagicMock( |
| 274 |
return_value=device_resp |
| 275 |
) |
| 276 |
info_module_mock.perform_module_operation() |
| 277 |
info_module_mock.powerflex_conn.device.get.assert_called() |
| 278 |
|
| 279 |
def test_get_device_details_exception(self, info_module_mock): |
| 280 |
self.get_module_args.update({ |
| 281 |
"gather_subset": ['device'] |
| 282 |
}) |
| 283 |
info_module_mock.module.params = self.get_module_args |
| 284 |
info_module_mock.powerflex_conn.device.get = MagicMock( |
| 285 |
side_effect=MockApiException |
| 286 |
) |
| 287 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 288 |
'device_get_details'), info_module_mock) |
| 289 |
|
| 290 |
def test_get_managed_device_details(self, info_module_mock): |
| 291 |
self.get_module_args.update({ |
| 292 |
"gather_subset": ['managed_device'] |
| 293 |
}) |
| 294 |
info_module_mock.module.params = self.get_module_args |
| 295 |
info_module_mock.powerflex_conn.managed_device.get = MagicMock() |
| 296 |
info_module_mock.perform_module_operation() |
| 297 |
info_module_mock.powerflex_conn.managed_device.get.assert_called() |
| 298 |
|
| 299 |
def test_get_managed_device_details_throws_exception(self, info_module_mock): |
| 300 |
self.get_module_args.update({ |
| 301 |
"gather_subset": ['managed_device'] |
| 302 |
}) |
| 303 |
info_module_mock.module.params = self.get_module_args |
| 304 |
info_module_mock.powerflex_conn.managed_device.get = MagicMock( |
| 305 |
side_effect=MockApiException |
| 306 |
) |
| 307 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 308 |
'managed_device_get_error'), info_module_mock) |
| 309 |
|
| 310 |
def test_get_service_template_details(self, info_module_mock): |
| 311 |
self.get_module_args.update({ |
| 312 |
"gather_subset": ['service_template'] |
| 313 |
}) |
| 314 |
info_module_mock.module.params = self.get_module_args |
| 315 |
info_module_mock.powerflex_conn.service_template.get = MagicMock() |
| 316 |
info_module_mock.perform_module_operation() |
| 317 |
info_module_mock.powerflex_conn.service_template.get.assert_called() |
| 318 |
|
| 319 |
def test_get_service_template_details_throws_exception(self, info_module_mock): |
| 320 |
self.get_module_args.update({ |
| 321 |
"gather_subset": ['service_template'] |
| 322 |
}) |
| 323 |
info_module_mock.module.params = self.get_module_args |
| 324 |
info_module_mock.powerflex_conn.service_template.get = MagicMock( |
| 325 |
side_effect=MockApiException |
| 326 |
) |
| 327 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 328 |
'service_template_get_error'), info_module_mock) |
| 329 |
|
| 330 |
def test_get_deployment_details(self, info_module_mock): |
| 331 |
self.get_module_args.update({ |
| 332 |
"gather_subset": ['deployment'], |
| 333 |
"limit": 20 |
| 334 |
}) |
| 335 |
info_module_mock.module.params = self.get_module_args |
| 336 |
info_module_mock.powerflex_conn.deployment.get = MagicMock() |
| 337 |
info_module_mock.perform_module_operation() |
| 338 |
info_module_mock.powerflex_conn.deployment.get.assert_called() |
| 339 |
|
| 340 |
def test_get_deployment_details_throws_exception(self, info_module_mock): |
| 341 |
self.get_module_args.update({ |
| 342 |
"gather_subset": ['deployment'] |
| 343 |
}) |
| 344 |
info_module_mock.module.params = self.get_module_args |
| 345 |
info_module_mock.powerflex_conn.deployment.get = MagicMock( |
| 346 |
side_effect=MockApiException |
| 347 |
) |
| 348 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 349 |
'deployment_get_error'), info_module_mock) |
| 350 |
|
| 351 |
def test_get_deployment_details_throws_exception_invalid_sort(self, info_module_mock): |
| 352 |
self.get_module_args.update({ |
| 353 |
"gather_subset": ['deployment'], |
| 354 |
"sort": 'invalid' |
| 355 |
}) |
| 356 |
info_module_mock.module.params = self.get_module_args |
| 357 |
info_module_mock.powerflex_conn.deployment.get = MagicMock( |
| 358 |
side_effect=MockApiException(INVALID_SORT_MSG) |
| 359 |
) |
| 360 |
info_module_mock.perform_module_operation() |
| 361 |
assert info_module_mock.get_deployments_list() == [] |
| 362 |
|
| 363 |
def test_get_with_multiple_gather_subset(self, info_module_mock): |
| 364 |
self.get_module_args.update({ |
| 365 |
"gather_subset": ['deployment', 'service_template'], |
| 366 |
"sort": 'name', "filters": [{"filter_key": "name", "filter_operator": "equal", "filter_value": "rack"}], |
| 367 |
}) |
| 368 |
info_module_mock.module.params = self.get_module_args |
| 369 |
info_module_mock.perform_module_operation() |
| 370 |
assert info_module_mock.populate_filter_list() == [] |
| 371 |
assert info_module_mock.get_param_value('sort') is None |
| 372 |
|
| 373 |
def test_get_with_invalid_offset_and_limit_for_subset(self, info_module_mock): |
| 374 |
self.get_module_args.update({ |
| 375 |
"gather_subset": ['deployment'], |
| 376 |
"limit": -1, "offset": -1 |
| 377 |
}) |
| 378 |
info_module_mock.module.params = self.get_module_args |
| 379 |
info_module_mock.perform_module_operation() |
| 380 |
assert info_module_mock.get_param_value('limit') is None |
| 381 |
assert info_module_mock.get_param_value('offset') is None |
| 382 |
|
| 383 |
def test_get_firmware_repository_details(self, info_module_mock): |
| 384 |
self.get_module_args.update({ |
| 385 |
"gather_subset": ['firmware_repository'], |
| 386 |
"limit": 20 |
| 387 |
}) |
| 388 |
info_module_mock.module.params = self.get_module_args |
| 389 |
info_module_mock.powerflex_conn.firmware_repository.get = MagicMock() |
| 390 |
info_module_mock.perform_module_operation() |
| 391 |
info_module_mock.powerflex_conn.firmware_repository.get.assert_called() |
| 392 |
|
| 393 |
def test_get_deployment_details_throws_exception(self, info_module_mock): |
| 394 |
self.get_module_args.update({ |
| 395 |
"gather_subset": ['firmware_repository'] |
| 396 |
}) |
| 397 |
info_module_mock.module.params = self.get_module_args |
| 398 |
info_module_mock.powerflex_conn.firmware_repository.get = MagicMock( |
| 399 |
side_effect=MockApiException |
| 400 |
) |
| 401 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 402 |
'firmware_repository_get_error'), info_module_mock) |
| 403 |
|
| 404 |
def test_get_nvme_host_details(self, info_module_mock): |
| 405 |
self.get_module_args.update({ |
| 406 |
"gather_subset": ['nvme_host'] |
| 407 |
}) |
| 408 |
info_module_mock.module.params = self.get_module_args |
| 409 |
nvme_host_resp = MockInfoApi.INFO_NVME_HOST_LIST |
| 410 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 411 |
return_value=nvme_host_resp |
| 412 |
) |
| 413 |
info_module_mock.perform_module_operation() |
| 414 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 415 |
|
| 416 |
def test_get_nvme_host_details_filter(self, info_module_mock): |
| 417 |
self.get_module_args.update({ |
| 418 |
"gather_subset": ['nvme_host'], |
| 419 |
"filters": [{ |
| 420 |
"filter_key": "name", |
| 421 |
"filter_operator": "equal", |
| 422 |
"filter_value": "fake_host_name_1" |
| 423 |
}] |
| 424 |
}) |
| 425 |
info_module_mock.module.params = self.get_module_args |
| 426 |
nvme_host_resp = MockInfoApi.INFO_SDC_FILTER_LIST |
| 427 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 428 |
return_value=nvme_host_resp |
| 429 |
) |
| 430 |
info_module_mock.perform_module_operation() |
| 431 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 432 |
|
| 433 |
def test_get_nvme_host_details_exception(self, info_module_mock): |
| 434 |
self.get_module_args.update({ |
| 435 |
"gather_subset": ['nvme_host'] |
| 436 |
}) |
| 437 |
info_module_mock.module.params = self.get_module_args |
| 438 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 439 |
side_effect=MockApiException |
| 440 |
) |
| 441 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 442 |
'nvme_host_get_details'), info_module_mock) |
| 443 |
|
| 444 |
def test_get_sdt_details(self, info_module_mock): |
| 445 |
self.get_module_args.update({ |
| 446 |
"gather_subset": ['sdt'] |
| 447 |
}) |
| 448 |
info_module_mock.module.params = self.get_module_args |
| 449 |
info_module_mock.powerflex_conn.sdt.get = MagicMock( |
| 450 |
return_value=MockInfoApi.INFO_GET_SDT_LIST |
| 451 |
) |
| 452 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 453 |
return_value=MockInfoApi.INFO_GET_SDT_NVME_HOST_LIST |
| 454 |
) |
| 455 |
info_module_mock.powerflex_conn.host.get_related = MagicMock( |
| 456 |
return_value=MockInfoApi.INFO_GET_SDT_NVME_CONTROLLER_LIST |
| 457 |
) |
| 458 |
info_module_mock.perform_module_operation() |
| 459 |
info_module_mock.powerflex_conn.sdt.get.assert_called() |
| 460 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 461 |
info_module_mock.powerflex_conn.host.get_related.assert_called() |
| 462 |
|
| 463 |
def test_get_sdt_details_filter(self, info_module_mock): |
| 464 |
self.get_module_args.update({ |
| 465 |
"gather_subset": ['sdt'], |
| 466 |
"filters": [{ |
| 467 |
"filter_key": "name", |
| 468 |
"filter_operator": "equal", |
| 469 |
"filter_value": "sdt-name", |
| 470 |
}] |
| 471 |
}) |
| 472 |
info_module_mock.module.params = self.get_module_args |
| 473 |
info_module_mock.powerflex_conn.sdt.get = MagicMock( |
| 474 |
return_value=MockInfoApi.INFO_GET_SDT_LIST |
| 475 |
) |
| 476 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 477 |
return_value=MockInfoApi.INFO_GET_SDT_NVME_HOST_LIST |
| 478 |
) |
| 479 |
info_module_mock.powerflex_conn.host.get_related = MagicMock( |
| 480 |
return_value=MockInfoApi.INFO_GET_SDT_NVME_CONTROLLER_LIST |
| 481 |
) |
| 482 |
info_module_mock.perform_module_operation() |
| 483 |
info_module_mock.powerflex_conn.sdt.get.assert_called() |
| 484 |
info_module_mock.powerflex_conn.sdc.get.assert_called() |
| 485 |
info_module_mock.powerflex_conn.host.get_related.assert_called() |
| 486 |
|
| 487 |
def test_get_sdt_details_exception(self, info_module_mock): |
| 488 |
self.get_module_args.update({ |
| 489 |
"gather_subset": ['sdt'] |
| 490 |
}) |
| 491 |
info_module_mock.module.params = self.get_module_args |
| 492 |
info_module_mock.powerflex_conn.sdc.get = MagicMock( |
| 493 |
side_effect=MockApiException |
| 494 |
) |
| 495 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 496 |
'sdt_get_error'), info_module_mock) |
| 497 |
|
| 498 |
def test_get_snapshot_policy_details_exception(self, info_module_mock): |
| 499 |
self.get_module_args.update({ |
| 500 |
"gather_subset": ['snapshot_policy'] |
| 501 |
}) |
| 502 |
info_module_mock.module.params = self.get_module_args |
| 503 |
info_module_mock.powerflex_conn.snapshot_policy.get = MagicMock( |
| 504 |
side_effect=MockApiException |
| 505 |
) |
| 506 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 507 |
'snapshot_policy_get_error'), info_module_mock) |
| 508 |
|
| 509 |
def test_get_array_details_exception(self, info_module_mock): |
| 510 |
info_module_mock.module.params = self.get_module_args |
| 511 |
info_module_mock.powerflex_conn.system.get = MagicMock( |
| 512 |
side_effect=MockApiException |
| 513 |
) |
| 514 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 515 |
'array_get_error'), info_module_mock) |
| 516 |
|
| 517 |
def test_get_version_exception(self, info_module_mock): |
| 518 |
info_module_mock.module.params = self.get_module_args |
| 519 |
info_module_mock.powerflex_conn.system.api_version = MagicMock( |
| 520 |
side_effect=MockApiException |
| 521 |
) |
| 522 |
self.capture_fail_json_call(MockInfoApi.get_exception_response( |
| 523 |
'version_get_error'), info_module_mock) |