def test_update_pass(self): """Verify update passes successfully.""" self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled", "host_connectivity_reporting": "disabled", "name": "array2"}) instance = NetAppESeriesGlobalSettings() instance.change_autoload_enabled_required = lambda: False instance.change_cache_block_size_required = lambda: False instance.change_cache_flush_threshold_required = lambda: False instance.change_host_type_required = lambda: False instance.change_name_required = lambda: False instance.change_host_connectivity_reporting_enabled_required = lambda: False with self.assertRaisesRegexp(AnsibleExitJson, r"'changed': False"): with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []), (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]), (200, {"autoLoadBalancingEnabled": True, "hostConnectivityReportingEnabled": True, "name": "array1"})] * 2): instance.update() self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled", "host_connectivity_reporting": "disabled", "name": "array2"}) instance = NetAppESeriesGlobalSettings() instance.change_autoload_enabled_required = lambda: True instance.change_cache_block_size_required = lambda: False instance.change_cache_flush_threshold_required = lambda: False instance.change_host_type_required = lambda: False instance.change_name_required = lambda: False instance.change_host_connectivity_reporting_enabled_required = lambda: False instance.update_autoload = lambda: None with self.assertRaisesRegexp(AnsibleExitJson, r"'changed': True"): with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []), (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]), (200, {"autoLoadBalancingEnabled": True, "hostConnectivityReportingEnabled": True, "name": "array1"})] * 2): instance.update()
def test_change_cache_flush_threshold_required_pass(self): """Verify change_cache_block_size_required passes successfully.""" self._set_args({"cache_block_size": 32768, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled", "host_connectivity_reporting": "enabled", "name": "array1"}) instance = NetAppESeriesGlobalSettings() instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768], "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80}, "default_host_type_index": 28, "host_connectivity_reporting_enabled": True, "host_type_options": {}, "name": 'array1'} self.assertFalse(instance.change_cache_flush_threshold_required()) self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled", "host_connectivity_reporting": "enabled", "name": "array1"}) instance = NetAppESeriesGlobalSettings() instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768], "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80}, "default_host_type_index": 28, "host_connectivity_reporting_enabled": True, "host_type_options": {}, "name": 'array1'} self.assertFalse(instance.change_cache_flush_threshold_required()) self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled", "host_connectivity_reporting": "enabled", "name": "array1"}) instance = NetAppESeriesGlobalSettings() instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768], "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80}, "default_host_type_index": 28, "host_connectivity_reporting_enabled": True, "host_type_options": {}, "name": 'array1'} self.assertTrue(instance.change_cache_flush_threshold_required())
def test_change_cache_flush_threshold_required_fail(self): """Verify change_cache_block_size_required throws expected exceptions.""" self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 100, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled", "host_connectivity_reporting": "enabled", "name": "array1"}) instance = NetAppESeriesGlobalSettings() instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768], "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80}, "default_host_type_index": 28, "host_connectivity_reporting_enabled": True, "host_type_options": {}, "name": 'array1'} with self.assertRaisesRegexp(AnsibleFailJson, r"Invalid cache flushing threshold, it must be equal to or between 0 and 100."): instance.change_cache_flush_threshold_required() self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 0, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled", "host_connectivity_reporting": "enabled", "name": "array1"}) instance = NetAppESeriesGlobalSettings() instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768], "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80}, "default_host_type_index": 28, "host_connectivity_reporting_enabled": True, "host_type_options": {}, "name": 'array1'} with self.assertRaisesRegexp(AnsibleFailJson, r"Invalid cache flushing threshold, it must be equal to or between 0 and 100."): instance.change_cache_flush_threshold_required()