Best Python code snippet using localstack_python
test_lambda_function.py
Source: test_lambda_function.py
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')...
lambda_function.py
Source: lambda_function.py
...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...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!