Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update email text

  • Loading branch information...
commit c2279d3cda5bcb8230d16d482c07f9066184c315 1 parent 0cb424c
@moqada authored
View
15 jserrorlogging/templates/jserrorlogging/email/body.txt
@@ -1,11 +1,12 @@
-{{ message|safe }}
+## {{ message|safe }}
-Where: {{ line }} in {% if page == url %}inline script{% else %}{{ url|safe }}{% endif %}
+Where: {{ line }} in {% if page == url %}inline script{% else %}{{ url|safe }}{% endif %}
UserAgent: {{ user_agent|safe }}
-When: {% if when == 'before' %}Before{% else %}After{% endif %} page load
-On Page: {{ page|safe }}
-Date: {{ created_at }}
+When: {% if when == 'before' %}Before{% else %}After{% endif %} page load
+On Page: {{ page|safe }}
+Date: {{ created_at|date:"Y-m-d H:i:s" }}
+UserID: {{ user_id }}
+SessionKey: {{ session_key }}
{% if meta %}
-Extras
-======{% for k , v in meta.items %}
+### Extras{% for k , v in meta.items %}
{{ k|safe }}: {{ v|safe }}{% endfor %}{% endif %}
View
40 jserrorlogging/tests.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import datetime
import json
+import mock
from django.test import TestCase
from django.core import mail
from django.test.utils import override_settings
@@ -148,3 +150,41 @@ def test_signal_notify_by_email(self):
mail.outbox[0].subject,
u'%sJS_ERROR: %s' % (settings.EMAIL_SUBJECT_PREFIX, data[0]['message']))
self.assertTrue(data[0]['message'] in mail.outbox[0].body, mail.outbox[0].body)
+
+
+class ReceiverNotifyByEmailTests(TestCase):
+ """ notify by email
+ """
+
+ def setUp(self):
+ # clear cache for notify interval
+ from django.core.cache import cache
+ cache.clear()
+
+ def _get_it(self):
+ from .receivers import notify_by_email
+ return notify_by_email
+
+ @mock.patch('django.utils.timezone.now')
+ def test_it_body(self, dummy_now):
+ dummy_now.return_value = datetime.datetime(2012, 12, 17, 10, 20)
+ data = create_dummy_error_data()
+ data.update(
+ user_id=1, session_key='dummy_session_key',
+ remote_addr='127.0.0.1',
+ created_at=dummy_now.return_value)
+ self._get_it()('sender', data=data)
+ from django.core import mail
+ data.update(created_at=data['created_at'].strftime('%Y-%m-%d %H:%M:%S'))
+ body = (
+ u'## %(message)s\n'
+ u'\n'
+ u'Where: %(line)s in %(url)s\n'
+ u'UserAgent: %(user_agent)s\n'
+ u'When: Before page load\n'
+ u'On Page: %(page)s\n'
+ u'Date: %(created_at)s\n'
+ u'UserID: %(user_id)s\n'
+ u'SessionKey: %(session_key)s\n\n'
+ ) % data
+ self.assertEqual(mail.outbox[0].body, body)
View
8 tox.ini
@@ -8,8 +8,12 @@ commands = python tests/manage.py test jserrorlogging
[testenv:py26-1.4]
basepython = python2.6
-deps = django==1.4.3
+deps =
+ django==1.4.3
+ mock
[testenv:py27-1.4]
basepython = python2.7
-deps = django==1.4.3
+deps =
+ django==1.4.3
+ mock
Please sign in to comment.
Something went wrong with that request. Please try again.