How to use disable_enhanced_monitoring method in localstack

Best Python code snippet using localstack_python

test_lambda_function.py

Source:test_lambda_function.py Github

copy

Full Screen

1######################################################################################################################2# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. #3# #4# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #5# with the License. A copy of the License is located at #6# #7# http://www.apache.org/licenses/LICENSE-2.0 #8# #9# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES #10# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions #11# and limitations under the License. #12######################################################################################################################13import unittest14import boto315import botocore.session16from botocore.stub import Stubber17from unittest.mock import patch18no_metrics = ['']19all_metrics = [20 'IncomingBytes',21 'IncomingRecords',22 'OutgoingBytes',23 'OutgoingRecords',24 'WriteProvisionedThroughputExceeded',25 'ReadProvisionedThroughputExceeded',26 'IteratorAgeMilliseconds'27]28class LambdaTest(unittest.TestCase):29 @classmethod30 def setUpClass(self):31 self._kinesis = botocore.session.get_session().create_client('kinesis')32 stubber = Stubber(self._kinesis)33 stubber.add_response('enable_enhanced_monitoring', {34 'StreamName': 'test-stream',35 'DesiredShardLevelMetrics': all_metrics36 })37 stubber.add_response('disable_enhanced_monitoring', {38 'StreamName': 'test-stream',39 'DesiredShardLevelMetrics': no_metrics40 })41 stubber.activate()42 @patch.object(boto3, 'client')43 def test_01_enable_monitoring(self, mock_client):44 mock_client.return_value = self._kinesis45 from lambda_function import _enhance_monitoring46 response_metrics = _enhance_monitoring('test-stream', 'true')47 self.assertCountEqual(all_metrics, response_metrics)48 @patch.object(boto3, 'client')49 def test_02_disable_monitoring(self, mock_client):50 mock_client.return_value = self._kinesis51 from lambda_function import _enhance_monitoring52 response_metrics = _enhance_monitoring('test-stream', 'false')...

Full Screen

Full Screen

lambda_function.py

Source:lambda_function.py Github

copy

Full Screen

...21 StreamName=stream_name,22 ShardLevelMetrics=shard_level_metrics23 )24 else:25 response = client.disable_enhanced_monitoring(26 StreamName=stream_name,27 ShardLevelMetrics=shard_level_metrics28 )29 return response['DesiredShardLevelMetrics']30@helper.create31@helper.update32def manage_enhanced_monitoring(event, _):33 _enhance_monitoring(34 event['ResourceProperties']['StreamName'],35 event['ResourceProperties']['EnableEnhancedMonitoring']36 )37@helper.delete38def no_op(_, __):39 pass # No action is required when stack is deleted...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful