Best Python code snippet using localstack_python
not_used_operations.py
Source:not_used_operations.py
1not_used_operations = {2 'ec2': [3 'describe_load_balancer_policies',4 'describe_vpc_endpoint_services',5 'describe_aggregate_id_format',6 'describe_load_balancer_policy_types',7 'describe_endpoints',8 'describe_availability_zones',9 'describe_account_attributes',10 'describe_dhcp_options',11 'describe_fpga_images',12 'describe_host_reservation_offerings',13 'describe_id_format',14 'describe_instance_event_notification_attributes',15 'describe_instance_type_offerings',16 'describe_instance_types',17 'describe_managed_prefix_lists',18 'describe_prefix_lists',19 'describe_regions',20 'describe_launch_template_versions',21 'describe_principal_id_format',22 'describe_spot_price_history',23 'describe_flow_logs',24 ### The blow 2 require extra parameters.25 'describe_images',26 'describe_snapshots',27 ],28 'ecr': [29 'get_authorization_token',30 ],31 'ecs': [32 'describe_capacity_providers',33 ],34 'efs': [35 'describe_account_preferences',36 ],37 'acm': [38 'get_account_configuration',39 ],40 'athena': [41 'list_data_catalogs',42 ],43 'apigateway': [44 'get_account',45 'get_sdk_types',46 ],47 'xray': [48 'get_encryption_config',49 'get_sample_rules',50 ],51 'waf': [52 'get_change_token',53 ],54 'waf-regional': [55 'get_change_token',56 ],57 'sts': [58 'get_caller_identity',59 'get_session_token',60 ],61 'ssm': [62 'describe_available_patches',63 'describe_patch_baselines',64 'get_inventory_schema',65 ],66 'ses': [67 'get_account_sending_enabled',68 'get_send_quota',69 ],70 'sesv2': [71 'get_account',72 'get_deliverability_dashboard_options',73 ],74 'signer': [75 'list_signing_platforms',76 ],77 'shield': [78 'describe_attack_statistics',79 'get_subscription_state',80 ],81 'lex-models': [82 'get_builtin_intents',83 'get_builtin_slot_types',84 ],85 'dynamodb': [86 'describe_limits',87 ],88 'lightsail': [89 'get_blueprints',90 'get_container_service_powers',91 'get_container_api_metadata',92 'get_bundles',93 'get_relational_database_blueprints',94 'get_relational_database_bundles',95 'get_regions',96 'get_bucket_bundles',97 ],98 'inspector': [99 'describe_cross_account_access_role',100 'list_rules_packages',101 ],102 'lambda': [103 'get_account_settings',104 ],105 'kinesis': [106 'describe_limits',107 ],108 'kafka': [109 'list_kafka_versions',110 'get_compatible_kafka_versions',111 ],112 'iot': [113 'describe_account_audit_configuration',114 'describe_event_configurations',115 'get_indexing_configuration',116 'get_registration_code',117 'list_domain_configurations'118 ],119 'iotsitewise': [120 'describe_logging_options',121 'describe_storage_configuration'122 ],123 'guardduty': [124 'get_invitations_count',125 ],126 'gamelift': [127 'describe_ec2_instance_limits',128 ],129 'elb': [130 'describe_account_limits',131 'describe_load_balancer_policies',132 ],133 'elbv2': [134 'describe_account_limits',135 'describe_ssl_policies',136 ],137 'elasticache': [138 'describe_cache_parameter_groups',139 'describe_service_updates',140 'list_allowed_node_type_modifications',141 'describe_cache_security_groups',142 'describe_users',143 ],144 'elasticbeanstalk': [145 'describe_account_attributes',146 'list_available_solution_stacks'147 ],148 'clouddirectory': [149 'list_managed_schema_arns',150 ],151 'codebuild': [152 'list_builds',153 'list_curated_environment_images'154 ],155 'cloudtrail': [156 'list_public_keys',157 'get_event_selectors',158 ],159 'cloudwatch': [160 'describe_alarm_history',161 'list_metrics',162 ],163 'snowball': [164 'get_snowball_usage',165 'list_compatible_images'166 ],167 'sms': [168 'get_servers'169 ],170 'sagemaker': [171 'get_sagemaker_servicecatalog_portfolio_status',172 ],173 'transfer': [174 'list_security_policies'175 ],176 'schemas': [177 'list_registries',178 ],179 'securityhub': [180 'describe_standards',181 ],182 'secretsmanager': [183 'get_random_password',184 ],185 'service-quotes': [186 'list_services',187 ],188 'wellarchitected': [189 'list_lenses',190 ],191 'route53': [192 'get_checker_ip_ranges',193 'get_geo_location',194 'get_traffic_policy_instance_count',195 'get_hosted_zone_count',196 'get_health_check_count',197 'list_geo_locations',198 ],199 'resourcegroupstaggingapi': [200 'get_resources',201 'get_tag_keys',202 ],203 'events': [204 'describe_event_bus',205 'list_event_buses',206 ],207 'fis': [208 'list_actions',209 ],210 'frauddetector': [211 'get_kms_encryption_key',212 ],213 'glacier': [214 'get_data_retrieval_policy',215 ],216 'glue': [217 'get_catalog_import_status',218 ],219 'apprunner': [220 'list_auto_scaling_configurations',221 ],222 'rds': [223 'describe_account_attributes',224 'describe_certificates',225 'describe_source_regions',226 ],227 'ram': [228 'list_permissions',229 ],230 'redshift': [231 'describe_account_attributes',232 'describe_cluster_tracks',233 'describe_orderable_cluster_options',234 'describe_storage',235 ],236 'polly': [237 'describe_voices',238 ],239 'opsworks': [240 'describe_my_user_profile',241 'describe_operating_systems',242 'describe_user_profiles',243 ],244 'opsworkscm': [245 'describe_account_attributes',246 ],247 'emr': [248 'get_block_public_access_configuration',249 'list_release_labels',250 ],251 'elastictranscoder': [252 'list_presets',253 ],254 'dms': [255 'describe_account_attributes',256 'describe_applicable_individual_assessments',257 'describe_orderable_replication_instances',258 ],259 'docdb': [260 'describe_certificates',261 'describe_db_subnet_groups',262 ],263 'ds': [264 'get_directory_limits',265 ],266 'compute-optimizer': [267 'get_enrollment_status',268 ],269 'config': [270 'get_compliance_summary_by_config_rule',271 'get_compliance_summary_by_resource_type',272 'get_discovered_resource_counts',273 ],274 'dax': [275 'describe_parameter_groups'276 ],277 'codedeploy': [278 'list_deployment_configs',279 ],280 'backup': [281 'list_backup_plan_templates',282 ],283 'autoscaling': [284 'describe_account_limits',285 ],286 'auditmanger': [287 'get_account_status',288 ],289 'cloudformation': [290 'describe_account_limits',291 ],292 'nimble': [293 'list_eulas',294 ],295 'cloudfront': [296 'list_cache_polocies',297 ]...
test_ses_service.py
Source:test_ses_service.py
1# -*- coding: utf-8 -*-2from datetime import (3 datetime,4 timezone)5import boto36import pytest7from botocore.stub import Stubber8from ses_account_monitor.services.ses_service import SesService9@pytest.fixture10def client():11 return boto3.client('ses',12 aws_access_key_id='a',13 aws_secret_access_key='b',14 region_name='us-west-2')15@pytest.fixture16def service(client):17 return SesService(client=client)18@pytest.fixture19def ses_quota_responses():20 return (({21 'Max24HourSend': 123.0,22 'MaxSendRate': 523.0,23 'SentLast24Hours': 0.024 }, 90, False), ({25 'Max24HourSend': 123.0,26 'MaxSendRate': 523.0,27 'SentLast24Hours': 123.028 }, 80, True), ({29 'Max24HourSend': 123.0,30 'MaxSendRate': 523.0,31 'SentLast24Hours': 150.032 }, 100, True), ({33 'Max24HourSend': 123.0,34 'MaxSendRate': 523.0,35 'SentLast24Hours': 123.036 }, None, True))37@pytest.fixture38def datetime_utc():39 dt = datetime(2018, 1, 1, 0, 0, 0, 0, tzinfo=timezone.utc)40 return dt41@pytest.fixture42def iso8601_date(datetime_utc):43 return datetime_utc.isoformat()44def test_get_account_sending_quota(client, service, ses_quota_responses):45 stubber = Stubber(client)46 stubber.add_response('get_send_quota',47 ses_quota_responses[0][0],48 {})49 with stubber:50 result = service.get_account_sending_quota()51 assert result == {52 'Max24HourSend': 123.0,53 'MaxSendRate': 523.0,54 'SentLast24Hours': 0.055 }56def test_is_account_sending_rate_over(client, service, ses_quota_responses):57 stubber = Stubber(client)58 for response, percentage, expected_result in ses_quota_responses:59 stubber.add_response('get_send_quota',60 response,61 {})62 stubber.activate()63 result = service.is_account_sending_rate_over(percentage)64 stubber.deactivate()65 assert result == expected_result66def test_toggle_account_sending(client, service):67 stubber = Stubber(client)68 stubber.add_response('get_account_sending_enabled',69 {'Enabled': True},70 {})71 stubber.add_response('update_account_sending_enabled',72 {},73 {'Enabled': False})74 stubber.add_response('get_account_sending_enabled',75 {'Enabled': False},76 {})77 stubber.add_response('update_account_sending_enabled',78 {},79 {'Enabled': True})80 with stubber:81 disable_result = service.toggle_account_sending()82 assert disable_result is False83 enable_result = service.toggle_account_sending()84 assert enable_result is True85def test_enable_account_sending(client, service):86 stubber = Stubber(client)87 stubber.add_response('update_account_sending_enabled',88 {},89 {'Enabled': True})90 with stubber:91 result = service.enable_account_sending()92 assert result is True93def test_disable_account_sending(client, service):94 stubber = Stubber(client)95 stubber.add_response('update_account_sending_enabled',96 {},97 {'Enabled': False})98 with stubber:99 result = service.disable_account_sending()100 assert result is False101def test_get_account_sending_current_percentage(client, service):102 stubber = Stubber(client)103 stubber.add_response('get_send_quota',104 {105 'Max24HourSend': 10.0,106 'MaxSendRate': 50.0,107 'SentLast24Hours': 0.0108 },109 {})110 stubber.add_response('get_send_quota',111 {112 'Max24HourSend': 123.0,113 'MaxSendRate': 523.0,114 'SentLast24Hours': 150.0115 },116 {})117 with stubber:118 zero_result = service.get_account_sending_current_percentage()119 assert zero_result == 0120 hundred_result = service.get_account_sending_current_percentage()121 assert hundred_result > 100122def test_get_account_sending_remaining_percentage(client, service):123 stubber = Stubber(client)124 stubber.add_response('get_send_quota',125 {126 'Max24HourSend': 10.0,127 'MaxSendRate': 50.0,128 'SentLast24Hours': 0.0129 },130 {})131 stubber.add_response('get_send_quota',132 {133 'Max24HourSend': 123.0,134 'MaxSendRate': 523.0,135 'SentLast24Hours': 150.0136 },137 {})138 with stubber:139 hundred_result = service.get_account_sending_remaining_percentage()140 assert hundred_result == 100141 zero_result = service.get_account_sending_remaining_percentage()142 assert zero_result == 0143def test_get_account_sending_stats(client, service, iso8601_date):144 stubber = Stubber(client)145 stubber.add_response('get_send_quota',146 {147 'Max24HourSend': 50.0,148 'MaxSendRate': 50.0,149 'SentLast24Hours': 10.0150 },151 {})152 with stubber:153 result = service.get_account_sending_stats(event_iso_ts=iso8601_date)...
check_ses.py
Source:check_ses.py
...55 args = init_argparse()56 conn = Conn(region=args.aws_region)57 now = datetime.datetime.utcnow()58 # Statistics59 enabled = conn.ses.get_account_sending_enabled()60 send_statistics = conn.ses.get_send_quota()61 try:62 live_statistics = sorted(conn.ses.get_send_statistics()['SendDataPoints'], key=lambda x: x[u'Timestamp'])[-1]63 except IndexError:64 live_statistics = {65 u'Complaints': 0,66 u'DeliveryAttempts': 0,67 u'Bounces': 0,68 u'Rejects': 0,69 u'Timestamp': now70 }71 if live_statistics[u'Timestamp'].replace(tzinfo=None) < now - datetime.timedelta(minutes=15):72 live_statistics = {73 u'Complaints': 0,...
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!!