Пример #1
0
 def test_email_subject_determined_from_template(self):
     """
     Ensures template subject is determined from template content
     """
     command = load_email_templates.Command()
     subject = command.get_subject(template)
     self.assertEqual(subject, 'Subject line!')
Пример #2
0
 def test_email_language_determined_from_template_file(self):
     """
     Ensures template language is determined from template file
     """
     command = load_email_templates.Command()
     file_ = '/var/www/src/plugs-auth/plugs_auth/templates/emails/account_activated_pt.html'
     language = command.get_template_language(file_)
     self.assertEqual(language, 'pt')
Пример #3
0
 def setUp(self):
     """
     Creates email templates
     """
     # uses the load email templates command to
     # auto populate our test database with email
     # templates
     command = load_email_templates.Command()
     command.handle()
Пример #4
0
 def test_raise_exception_if_template_language_is_missing(self):
     """
     Ensures exception raised of template file is missing language code
     """
     command = load_email_templates.Command()
     file_ = '/var/www/src/plugs-auth/plugs_auth/templates/emails/account_activated.html'
     with self.assertRaisesMessage(
             Exception,
             'Template file must end in ISO_639-1 language code.'):
         language = command.get_template_language(file_)
Пример #5
0
 def test_create_text_template_from_html_version(self):
     """
     Ensures a template text version is created from the html version
     """
     html_template = '<p>Bacon ipsum dolor amet <b>picanha</b> bacon ribeye <i>salami</i> meatloaf beef</p>'
     command = load_email_templates.Command()
     result = command.text_version(html_template)
     self.assertEqual(
         result,
         'Bacon ipsum dolor amet picanha bacon ribeye salami meatloaf beef\n\n'
     )
Пример #6
0
 def test_email_content_determined_from_template(self):
     """
     Ensures template content is determined from template content
     """
     command = load_email_templates.Command()
     html_content = command.get_html_content(template)
     expected = '{% extends "base.html" %}\n' \
                '{% block content %}\n' \
                '<p>Hello,</p>\n' \
                '<p>Test Message.</p>\n' \
                '{% endblock %}\n'
     self.assertEqual(html_content, expected)