def test_to_addresses(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.return_value = True smtp = send_email(['*****@*****.**', '*****@*****.**'], '', '', attachment='None') self.assertEqual(smtp.sendmail.call_args[0][1], ['*****@*****.**', '*****@*****.**']) smtp = send_email('*****@*****.**', '', '', attachment='None') self.assertEqual(smtp.sendmail.call_args[0][1], '*****@*****.**')
def test_to_addresses(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.side_effect = true_side_effect messaging.send_emails_override = None smtp = messaging.send_email(['*****@*****.**', '*****@*****.**'], '', '') # pylint: disable=no-member self.assertEqual(smtp.sendmail.call_args[0][1], ['*****@*****.**', '*****@*****.**']) smtp = messaging.send_email('*****@*****.**', '', '') self.assertEqual(smtp.sendmail.call_args[0][1], '*****@*****.**')
def test_string_body(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.side_effect = true_side_effect messaging.send_emails_override = None smtp = messaging.send_email('*****@*****.**', 'subject', 'body') # pylint: disable=no-member self.assertIn('Subject: subject', smtp.sendmail.call_args[0][2]) self.assertIn('body', smtp.sendmail.call_args[0][2])
def test_string_body(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.return_value = True smtp = send_email('*****@*****.**', 'subject', 'body', attachment='None') self.assertIn('Subject: subject', smtp.sendmail.call_args[0][2]) self.assertIn('body', smtp.sendmail.call_args[0][2])
def test_html_body(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.return_value = True message = MIMEMultipart() message.attach(MIMEText('<p>test</p>', 'html')) message.attach(MIMEText('test')) smtp = send_email('*****@*****.**', 'subject', message, attachment='None') self.assertIn('test', smtp.sendmail.call_args[0][2])
def test_html_body(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.side_effect = true_side_effect message = MIMEMultipart() message.attach(MIMEText('<p>test</p>', 'html')) message.attach(MIMEText('test')) smtp = messaging.send_email('*****@*****.**', 'subject', message) # pylint: disable=no-member self.assertIn('test', smtp.sendmail.call_args[0][2])
def test_send_emails_override(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.side_effect = false_side_effect messaging.send_emails_override = False self.assertIsNone(messaging.send_email('*****@*****.**', 'subject', 'body')) get_config_prop_mock.return_value = True messaging.send_emails_override = False self.assertIsNone(messaging.send_email('*****@*****.**', 'subject', 'body')) get_config_prop_mock.return_value = True messaging.send_emails_override = True self.assertIsNotNone(messaging.send_email('*****@*****.**', 'subject', 'body')) get_config_prop_mock.side_effect = false_side_effect messaging.send_emails_override = True self.assertIsNotNone(messaging.send_email('*****@*****.**', 'subject', 'body'))
def test_send_emails_false(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.side_effect = false_side_effect self.assertIsNone(messaging.send_email('*****@*****.**', 'subject', 'body'))
def test_send_emails_false(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.return_value = False self.assertIsNone( send_email('*****@*****.**', 'subject', 'body', attachment='None'))
def test_send_emails_false(self, SMTP_mock, get_config_prop_mock): get_config_prop_mock.return_value = False self.assertIsNone(send_email('*****@*****.**', 'subject', 'body', attachment='None'))
log.info('creating crate') crate = Crate(sgid_name, sgid_db, stage_db, sgid_name) log.info('processing crate') core.init(log) crate.set_result(core.update(crate, validate_crate)) if crate.was_updated(): log.info('updating data in SDE') sgid_destination = path.join(sgid_db, 'SGID10.ENVIRONMENT.{}'.format(sgid_name)) arcpy.management.TruncateTable(sgid_destination) arcpy.management.Append(crate.destination, sgid_destination, 'NO_TEST') log.info('updating prod fgdbs') for dest_fgdb in [settings.mapData1, settings.mapData2]: dest = path.join(dest_fgdb, 'deqquerylayers.gdb', sgid_name) arcpy.management.TruncateTable(dest) arcpy.management.Append(crate.destination, dest, 'NO_TEST') if crate.result[0] in bad_results: send_email(reportEmail, 'DEQ Hourly Crate Error', 'Crate Result: \n{}'.format(crate.result)) log.info('Process completed successfully. Have a nice day.') except Exception as e: log.error(format_exc()) send_email(reportEmail, 'DEQ Hourly Script Error', format_exc()) finally: shutdown()