def test_scaledownlist_with_anytype_and_without_transaction(self): _ctx = self._gen_ctx() client = self._gen_rest_client() with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): # can downscale without errors fake_run_scale = Mock(return_value=None) with patch( "cloudify_scalelist.workflows._run_scale_settings", fake_run_scale ): workflows.scaledownlist( ctx=_ctx, scale_node_field="name", scale_node_field_value=["value"] ) fake_run_scale.assert_called_with( _ctx, { 'alfa_types': { 'instances': 54, 'removed_ids_include_hint': ['a_id'] } }, {}, instances_remove_ids=['a_id'], ignore_failure=False)
def test_scaledownlist(self): _ctx = self._gen_ctx() client = self._gen_rest_client() with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): # can downscale without errors fake_run_scale = Mock(return_value=None) with patch( "cloudify_scalelist.workflows._run_scale_settings", fake_run_scale ): workflows.scaledownlist( ctx=_ctx, scale_transaction_field='_transaction', scale_node_name="a", scale_node_field="name", scale_node_field_value="value" ) fake_run_scale.assert_called_with( _ctx, { 'alfa_types': { 'instances': 54, 'removed_ids_include_hint': ['a_id', 'b_id'] } }, {}, instances_remove_ids=['a_id', 'b_id'], ignore_failure=False) # we have downscale issues fake_run_scale = Mock(side_effect=ValueError("No Down Scale!")) with patch( "cloudify_scalelist.workflows._run_scale_settings", fake_run_scale ): fake_uninstall_instances = Mock(return_value=None) with patch( "cloudify_scalelist.workflows._uninstall_instances", fake_uninstall_instances ): workflows.scaledownlist( ctx=_ctx, scale_transaction_field='_transaction', scale_node_name="a", scale_node_field="name", scale_node_field_value="value" ) fake_uninstall_instances.assert_called_with(_ctx, _ctx.graph_mode(), ['a_id', 'b_id'], [], False) fake_run_scale.assert_called_with( _ctx, { 'alfa_types': { 'instances': 54, 'removed_ids_include_hint': ['a_id', 'b_id'] } }, {}, instances_remove_ids=['a_id', 'b_id'], ignore_failure=False)
def test_empty_scaledown_params(self): # empty values with self.assertRaises(ValueError): workflows.scaledownlist(ctx=Mock()) # no noes with such value _ctx = self._gen_ctx() client = self._gen_rest_client() client.node_instances.list = Mock(return_value=[]) with patch( "cloudify_scalelist.workflows.get_rest_client", Mock(return_value=client) ): workflows.scaledownlist( ctx=_ctx, scale_transaction_field='_transaction', scale_node_name="node", scale_node_field="name", scale_node_field_value="value" ) client.node_instances.list.assert_called_with( _include=['runtime_properties', 'node_id', 'id'], deployment_id='deployment_id')