Best Python code snippet using localstack_python
test_cloudformation_logs.py
Source: test_cloudformation_logs.py
...5 os.path.dirname(__file__), "../templates/logs_group_and_stream.yaml"6 )7 )8 # approach 1: cloudformation_api + custom transformer for key_value "LogGroupNameOutput"9 snapshot.add_transformer(snapshot.transform.cloudformation_api())10 snapshot.add_transformer(snapshot.transform.key_value("LogGroupNameOutput"))11 # approach 2: cloudformation_api + two custom replacements with priority for LogStreamNameOutput12 # snapshot.add_transformer(snapshot.transform.cloudformation_api())13 # snapshot.add_transformer(snapshot.transform.key_value("LogStreamNameOutput"), priority=-1)14 # snapshot.add_transformer(snapshot.transform.key_value("LogGroupNameOutput"))15 # approach 3: two custom transformer:16 # snapshot.add_transformer(snapshot.transform.key_value("LogStreamNameOutput"))17 # snapshot.add_transformer(snapshot.transform.key_value("LogGroupNameOutput"))18 group_name = stack.outputs["LogGroupNameOutput"]19 stream_name = stack.outputs["LogStreamNameOutput"]20 # lets assert this by snapshot -> it's not aws response, but outputs is a dict, so we can use it here21 # assert group_name22 # assert stream_name23 snapshot.match("outputs", stack.outputs)24 streams = logs_client.describe_log_streams(25 logGroupName=group_name, logStreamNamePrefix=stream_name26 )["logStreams"]...
test_cloudformation_api.py
Source: test_cloudformation_api.py
1import json2from importlib.resources import open_text3from unittest import mock4from botocore.exceptions import ClientError5from django.test import TestCase6from djaws import s3_api, cloudformation_api7from djaws.cloudformation.exceptions import CFError8class DescribeStacksTests(TestCase):9 @classmethod10 def setUpTestData(cls):11 with open_text('djaws.tests.schemas.cloudformation', 'describe_stacks.json') as cf_json:12 cls.r_stacks_data = json.loads(cf_json.read())13 @mock.patch.object(cloudformation_api, 'cf_session_client')14 def test_ok(self, mock_client):15 mock_client.describe_stacks.return_value = self.r_stacks_data16 r_stacks = cloudformation_api.describe_stacks(17 mock_client,18 stack_name='test123',19 )20 self.assertTrue(r_stacks.first_stack.stack_status, 'CREATE_COMPLETE')21 @mock.patch.object(cloudformation_api, 'cf_session_client')22 def test_validation_error(self, mock_client):23 mock_client.describe_stacks.side_effect = ClientError(24 {25 'Error': {26 'Code': 'ValidationError',27 'Message': 'Details/context around the exception or error'28 },29 'ResponseMetadata': {30 'RequestId': '1234567890ABCDEF',31 'HostId': 'host ID data will appear here as a hash',32 'HTTPStatusCode': 400,33 'HTTPHeaders': {'header metadata key/values will appear here'},34 'RetryAttempts': 035 }36 },37 'generate_presigned_post'38 )39 with self.assertRaises(CFError):40 cloudformation_api.describe_stacks(41 mock_client,42 stack_name='test123',...
describe_stacks.py
Source: describe_stacks.py
1from django.core.management.base import BaseCommand2from djaws import cloudformation_api3class Command(BaseCommand):4 help = 'Describe Cloud Formation Stack'5 def add_arguments(self, parser):6 parser.add_argument(7 "--stack_name",8 type=str,9 help="S3 Region",10 )11 def handle(self, *args, **kwargs):12 stack_name = kwargs['stack_name']13 cf_client = cloudformation_api.cf_session_client()14 try:15 r_stacks = cloudformation_api.describe_stacks(cf_client, stack_name=stack_name)16 except Exception as e:17 self.stdout.write(self.style.ERROR(f'Error while running command:\n{str(e)}'))18 raise e19 else:20 stack = r_stacks.first_stack21 self.stdout.write(self.style.MIGRATE_LABEL(f'Successfully got stack details.'))22 msg = f'id: {stack.stack_id}\nname: {stack.stack_name}\nstatus: {stack.stack_status}'...
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!!