Best Python code snippet using localstack_python
conftest.py
Source:conftest.py
...32 with mock_s3():33 s3_client: S3Client = boto3.client("s3")34 s3_client.create_bucket(Bucket="firehose-test")35 client = boto3.client("firehose", region_name="eu-west-2")36 client.create_delivery_stream(37 DeliveryStreamName=logging_client.stream_name,38 ExtendedS3DestinationConfiguration={39 "BucketARN": "arn:aws:s3:::firehose-test",40 "BufferingHints": {"IntervalInSeconds": 300, "SizeInMBs": 5},41 "CompressionFormat": "UNCOMPRESSED",42 "DataFormatConversionConfiguration": {"Enabled": False},43 "EncryptionConfiguration": {"NoEncryptionConfig": "NoEncryption"},44 "Prefix": "AWSLogs/000000000000/route53querylogs/eu-west-2/",45 "ProcessingConfiguration": {"Enabled": False, "Processors": []},46 "RoleARN": "arn:aws:iam::000000000000:role/query-log-firehose-P8V0BH6695TQ7HD",47 "S3BackupMode": "Disabled",48 },49 )50 yield s3_client51# TODO: DRY this up: can we pass in the logging client somehow?52@pytest.fixture(scope="function")53def dummy_log_stream(sts, firehose):54 with mock_s3():55 s3_client: S3Client = boto3.client("s3")56 s3_client.create_bucket(Bucket="firehose-test")57 client = boto3.client("firehose", region_name="eu-west-2")58 client.create_delivery_stream(59 DeliveryStreamName=DummyLoggingClient.stream_name,60 ExtendedS3DestinationConfiguration={61 "BucketARN": "arn:aws:s3:::firehose-test",62 "BufferingHints": {"IntervalInSeconds": 300, "SizeInMBs": 5},63 "CompressionFormat": "UNCOMPRESSED",64 "DataFormatConversionConfiguration": {"Enabled": False},65 "EncryptionConfiguration": {"NoEncryptionConfig": "NoEncryption"},66 "Prefix": "AWSLogs/000000000000/route53querylogs/eu-west-2/",67 "ProcessingConfiguration": {"Enabled": False, "Processors": []},68 "RoleARN": "arn:aws:iam::000000000000:role/query-log-firehose-P8V0BH6695TQ7HD",69 "S3BackupMode": "Disabled",70 },71 )72 yield s3_client73@pytest.fixture(scope="function")74def dc_wide_postcode_log_stream(sts, firehose):75 with mock_s3():76 s3_client: S3Client = boto3.client("s3")77 s3_client.create_bucket(Bucket="firehose-test")78 client = boto3.client("firehose", region_name="eu-west-2")79 client.create_delivery_stream(80 DeliveryStreamName=DCWidePostcodeLoggingClient.stream_name,81 ExtendedS3DestinationConfiguration={82 "BucketARN": "arn:aws:s3:::firehose-test",83 "BufferingHints": {"IntervalInSeconds": 300, "SizeInMBs": 5},84 "CompressionFormat": "UNCOMPRESSED",85 "DataFormatConversionConfiguration": {"Enabled": False},86 "EncryptionConfiguration": {"NoEncryptionConfig": "NoEncryption"},87 "Prefix": "AWSLogs/000000000000/route53querylogs/eu-west-2/",88 "ProcessingConfiguration": {"Enabled": False, "Processors": []},89 "RoleARN": "arn:aws:iam::000000000000:role/query-log-firehose-P8V0BH6695TQ7HD",90 "S3BackupMode": "Disabled",91 },92 )93 yield s3_client
test_utils.py
Source:test_utils.py
1from moto.core import ACCOUNT_ID2def create_redshift_delivery_stream(client, stream_name):3 return client.create_delivery_stream(4 DeliveryStreamName=stream_name,5 RedshiftDestinationConfiguration={6 "RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(ACCOUNT_ID),7 "ClusterJDBCURL": "jdbc:redshift://host.amazonaws.com:5439/database",8 "CopyCommand": {9 "DataTableName": "outputTable",10 "CopyOptions": "CSV DELIMITER ',' NULL '\\0'",11 },12 "Username": "username",13 "Password": "password",14 "S3Configuration": {15 "RoleARN": "arn:aws:iam::{}:role/firehose_delivery_role".format(16 ACCOUNT_ID17 ),18 "BucketARN": "arn:aws:s3:::kinesis-test",19 "Prefix": "myFolder/",20 "BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},21 "CompressionFormat": "UNCOMPRESSED",22 },23 },24 )25def create_delivery_stream(client, stream_name):26 return client.create_delivery_stream(27 DeliveryStreamName=stream_name,28 S3DestinationConfiguration={29 "RoleARN": f"arn:aws:iam::{ACCOUNT_ID}:role/firehose_delivery_role",30 "BucketARN": "arn:aws:s3:::kinesis-test",31 "Prefix": "myFolder/",32 "BufferingHints": {"SizeInMBs": 123, "IntervalInSeconds": 124},33 "CompressionFormat": "UNCOMPRESSED",34 }...
createDeliveryStream.py
Source:createDeliveryStream.py
1import boto32def create_delivery_stream(deliveryStream,streamType,streamARN,roleARN,s3ARN):3 firehose = boto3.client('firehose') 4 response = fireshose.create_delivery_stream(5 DeliveryStreamName = deliveryStream,6 DeliveryStreamType = streamType,7 KinesisStreamSourceConfiguration ={8 'KinesisStreamARN': streamARN,9 'RoleARN' : roleARN10 },11 S3DestinationConfiguration = {12 'RoleARN': s3ARN,13 'BucketARN': bucketARN14 } 15 )...
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!!