# Path: brasilcomvc/common/email.py
# def send_template_email(subject, to, template_name, context=None):
#     '''
#     Render a template into an email body and send it through Django's send_mail
# 
#     - The `to` parameter must be a single email address.
#     - This function omits `from_email` because it expects it to exist from an
#     environment variable.
#     - Other parameters are omitted as well because there are no
#     use for them in the current use case.
#     '''
#     body = render_to_string(template_name, context or {}, Context({
#         'mailing_address': settings.MAILING_ADDRESS,
#         'site_url': settings.BASE_URL,
#         'sns_facebook': settings.SNS_FACEBOOK,
#         'sns_googleplus': settings.SNS_GOOGLEPLUS,
#         'sns_twitter': settings.SNS_TWITTER,
#         'subject': subject,
#     }))
#     plain_body = strip_tags(body)
# 
#     email = EmailMultiAlternatives(
#         subject=subject,
#         body=plain_body,
#         to=(to,))
#     email.attach_alternative(body, 'text/html')
#     email.send()


from datetime import datetime
from django.core import mail
from django.test import TestCase
from ..email import send_template_email




class TemplateEmailTestCase(TestCase):

    def test_email_should_be_sent(self):
        send_template_email('test', 'user@localhost', 'test_email.html')
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'test')
        self.assertEqual(mail.outbox[0].to[0], 'user@localhost')

    def test_email_should_render_plain_text_correctly(self):
        timestamp = str(datetime.now())

# Path: brasilcomvc/common/email.py
# def send_template_email(subject, to, template_name, context=None):
#     '''
#     Render a template into an email body and send it through Django's send_mail
# 
#     - The `to` parameter must be a single email address.
#     - This function omits `from_email` because it expects it to exist from an
#     environment variable.
#     - Other parameters are omitted as well because there are no
#     use for them in the current use case.
#     '''
#     body = render_to_string(template_name, context or {}, Context({
#         'mailing_address': settings.MAILING_ADDRESS,
#         'site_url': settings.BASE_URL,
#         'sns_facebook': settings.SNS_FACEBOOK,
#         'sns_googleplus': settings.SNS_GOOGLEPLUS,
#         'sns_twitter': settings.SNS_TWITTER,
#         'subject': subject,
#     }))
#     plain_body = strip_tags(body)
# 
#     email = EmailMultiAlternatives(
#         subject=subject,
#         body=plain_body,
#         to=(to,))
#     email.attach_alternative(body, 'text/html')
#     email.send()


# Path: brasilcomvc/common/tests/test_email.py
from datetime import datetime
from django.core import mail
from django.test import TestCase
from ..email import send_template_email





class TemplateEmailTestCase(TestCase):

    def test_email_should_be_sent(self):
        send_template_email('test', 'user@localhost', 'test_email.html')
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'test')
        self.assertEqual(mail.outbox[0].to[0], 'user@localhost')

    def test_email_should_render_plain_text_correctly(self):
        timestamp = str(datetime.now())

        send_template_email(