Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

test_customer.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. from django.test import TestCase
  2. from oscar.core.compat import get_user_model
  3. from oscar.apps.customer.models import CommunicationEventType
  4. User = get_user_model()
  5. class CommunicationTypeTest(TestCase):
  6. keys = ('body', 'html', 'sms', 'subject')
  7. def test_no_templates_returns_empty_string(self):
  8. et = CommunicationEventType()
  9. messages = et.get_messages()
  10. for key in self.keys:
  11. self.assertEqual('', messages[key])
  12. def test_field_template_render(self):
  13. et = CommunicationEventType(email_subject_template='Hello {{ name }}')
  14. ctx = {'name': 'world'}
  15. messages = et.get_messages(ctx)
  16. self.assertEqual('Hello world', messages['subject'])
  17. def test_new_line_in_subject_is_removed(self):
  18. subjects = [
  19. ('Subject with a newline\r\n', 'Subject with a newline'),
  20. ('New line is in \n the middle', 'New line is in the middle'),
  21. ('\rStart with the new line', 'Start with the new line'),
  22. ]
  23. for original, modified in subjects:
  24. et = CommunicationEventType(email_subject_template=original)
  25. messages = et.get_messages()
  26. self.assertEqual(modified, messages['subject'])