How to use get_send_quota method in localstack

Best Python code snippet using localstack_python

test_ses.py

Source:test_ses.py Github

copy

Full Screen

...83 assert cls._have_usage is False84 cls.find_usage()85 assert mock_connect.mock_calls == [call()]86 assert cls._have_usage is True87 assert mock_conn.mock_calls == [call.get_send_quota()]88 assert len(cls.limits['Daily sending quota'].get_current_usage()) == 189 assert cls.limits['Daily sending quota'].get_current_usage()[90 0].get_value() == 122.091 def test_find_usage_invalid_region(self):92 def se_get():93 raise EndpointConnectionError(endpoint_url='myurl')94 mock_conn = Mock()95 mock_conn.get_send_quota.side_effect = se_get96 with patch('%s.connect' % pb) as mock_connect:97 with patch('%s.logger' % pbm) as mock_logger:98 cls = _SesService(21, 43)99 cls.conn = mock_conn100 assert cls._have_usage is False101 cls.find_usage()102 assert mock_connect.mock_calls == [call()]103 assert cls._have_usage is False104 assert mock_logger.mock_calls == [105 call.debug('Checking usage for service %s', 'SES'),106 call.warn(107 'Skipping SES: %s',108 'Could not connect to the endpoint URL: "myurl"'109 )110 ]111 assert mock_conn.mock_calls == [call.get_send_quota()]112 assert len(cls.limits['Daily sending quota'].get_current_usage()) == 0113 def test_update_limits_from_api(self):114 mock_conn = Mock()115 mock_conn.get_send_quota.return_value = {116 'Max24HourSend': 123.0,117 'MaxSendRate': 12.0,118 'SentLast24Hours': 122.0119 }120 with patch('%s.connect' % pb) as mock_connect:121 cls = _SesService(21, 43)122 cls.conn = mock_conn123 cls._update_limits_from_api()124 assert mock_connect.mock_calls == [call()]125 assert mock_conn.mock_calls == [call.get_send_quota()]126 assert cls.limits['Daily sending quota'].api_limit == 123.0127 def test_update_limits_from_api_invalid_region(self):128 def se_get():129 raise EndpointConnectionError(endpoint_url='myurl')130 mock_conn = Mock()131 mock_conn.get_send_quota.side_effect = se_get132 with patch('%s.connect' % pb) as mock_connect:133 with patch('%s.logger' % pbm) as mock_logger:134 cls = _SesService(21, 43)135 cls.conn = mock_conn136 cls._update_limits_from_api()137 assert mock_connect.mock_calls == [call()]138 assert mock_conn.mock_calls == [call.get_send_quota()]139 assert mock_logger.mock_calls == [140 call.warn(141 'Skipping SES: %s',142 'Could not connect to the endpoint URL: "myurl"'143 )144 ]145 assert cls.limits['Daily sending quota'].api_limit is None146 def test_required_iam_permissions(self):147 cls = _SesService(21, 43)148 assert cls.required_iam_permissions() == [149 'ses:GetSendQuota'...

Full Screen

Full Screen

test_send_email.py

Source:test_send_email.py Github

copy

Full Screen

...24 sesMailSender = SesMailSender(conn)25 self.assertRaises(ClientError, sesMailSender.send_email, emailBody)26 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")27 sesMailSender.send_email(emailBody)28 send_quota = conn.get_send_quota()29 sent_count = int(send_quota["SentLast24Hours"])30 self.assertEqual(sent_count, 3)31 @mock_ses32 def test_send_template_email(self):33 conn = boto3.client("ses", region_name="us-east-2")34 conn.create_template(35 Template={36 "TemplateName": "MyTemplate",37 "SubjectPart": "lalala",38 "HtmlPart": "1111",39 "TextPart": "1111",40 }41 )42 emailBody = EmailBody(source="xu.liang@cienet.com.cn",43 destination="liangxudoit@163.com",44 template_name="MyTemplate",45 template_data={"name": "Alejandro", "favoriteanimal": "alligator"},46 cc="1209514536@qq.com",47 bcc="1209514536@qq.com",48 reply_tos="1209514536@qq.com"49 )50 sesMailSender = SesMailSender(conn)51 self.assertRaises(ClientError, sesMailSender.send_templated_email, emailBody)52 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")53 sesMailSender.send_templated_email(emailBody)54 send_quota = conn.get_send_quota()55 sent_count = int(send_quota["SentLast24Hours"])56 self.assertEqual(sent_count, 3)57 @mock_ses58 def test_send_appconfig_email_complete(self):59 conn = boto3.client("ses")60 appconfig_result = AppConfigResult(0, "12", "123", "12345", AppconfigState.COMPLETE.value, "",61 "shipoption/test1.json")62 sesMailSender = SesMailSender(conn)63 email = sesMailSender.send_appconfig_email(appconfig_result)64 self.assertEqual(email, None)65 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")66 sesMailSender.send_appconfig_email(appconfig_result)67 send_quota = conn.get_send_quota()68 sent_count = int(send_quota["SentLast24Hours"])69 self.assertEqual(sent_count, 1)70 @mock_ses71 def test_send_appconfig_email_error(self):72 conn = boto3.client("ses")73 message_dict = {'This sheet 2th row has error': ['Ship Option ID is not null', 'Ship Option Name is not null'],74 'This sheet 3th row has error': ['Ship Option ID is null', 'Ship Option Name is not null']75 }76 appconfig_result = AppConfigResult(0, "12", "123", "12345", AppconfigState.VERIFY_ERROR.value, message_dict,77 "shipoption/test1.json")78 sesMailSender = SesMailSender(conn)79 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")80 sesMailSender.send_appconfig_email(appconfig_result)81 send_quota = conn.get_send_quota()82 sent_count = int(send_quota["SentLast24Hours"])83 self.assertEqual(sent_count, 1)84 @mock_ses85 def test_send_appconfig_template_email_error(self):86 conn = boto3.client("ses")87 message_dict = {'This sheet 2th row has error': ['Ship Option ID is not null', 'Ship Option Name is not null'],88 'This sheet 3th row has error': ['Ship Option ID is null', 'Ship Option Name is not null']89 }90 appconfig_result = AppConfigResult(0, "12", "123", "12345", AppconfigState.VERIFY_ERROR.value, message_dict,91 "shipoption/test1.json")92 sesMailSender = SesMailSender(conn)93 email = sesMailSender.send_appconfig_templated_email(appconfig_result)94 self.assertEqual(email, None)95 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")96 conn.create_template(97 Template={98 "TemplateName": "SendEmailAppConfigError",99 "SubjectPart": "lalala",100 "HtmlPart": "1111",101 "TextPart": "1111",102 }103 )104 sesMailSender.send_appconfig_templated_email(appconfig_result)105 send_quota = conn.get_send_quota()106 sent_count = int(send_quota["SentLast24Hours"])107 self.assertEqual(sent_count, 1)108 @mock_ses109 def test_send_appconfig_template_email_common(self):110 conn = boto3.client("ses")111 message_dict = {}112 appconfig_result = AppConfigResult(0, "12", "123", "12345", AppconfigState.COMPLETE.value, message_dict,113 "shipoption/test1.json")114 sesMailSender = SesMailSender(conn)115 conn.verify_email_address(EmailAddress="xu.liang@cienet.com.cn")116 conn.create_template(117 Template={118 "TemplateName": "SendEmailAppConfigCommon",119 "SubjectPart": "lalala",120 "HtmlPart": "1111",121 "TextPart": "1111",122 }123 )124 sesMailSender.send_appconfig_templated_email(appconfig_result)125 send_quota = conn.get_send_quota()126 sent_count = int(send_quota["SentLast24Hours"])127 self.assertEqual(sent_count, 1)128if __name__ == '__main__':...

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