Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test sentry.contrib.django

  • Loading branch information...
commit fe383b0cd0d638cf39fa8e7d8702e1c027a6d170 1 parent 01bec71
@gandalfar gandalfar authored
View
2  tests/test_contrib/django/bad_templates/404.html
@@ -1,4 +1,4 @@
-{# {% block foo %} #}
+{% block foo %}
This template is deliberately bad - we want it to raise an exception when it is used.
View
26 tests/test_contrib/django/test_django.py
@@ -1,6 +1,7 @@
from ... import BaseTest
from django.conf import settings
+from os.path import join, dirname
if not settings.configured:
settings.configure(
@@ -25,8 +26,8 @@
'djcelery', # celery client
- 'sentry',
- 'sentry.client.django',
+ # 'sentry',
+ 'sentry.contrib.django',
],
TEMPLATE_DIRS = (join(dirname(__file__), 'bad_templates'),),
ROOT_URLCONF='tests.test_contrib.django.urls',
@@ -83,3 +84,24 @@ def test_exception_handler(self):
self.assertTrue('id' in frame)
self.assertTrue('filename' in frame)
+ def test_django_testclient(self):
+ from django.test import Client
+ from django.template import TemplateSyntaxError
+ c = Client()
+
+ try:
+ response = c.get("/no_such_view/")
+ except TemplateSyntaxError:
+ pass
+
+ event = Event.objects.all()[0]
+ data = event.data
+
+ self.assertTrue('sentry.interfaces.Exception' in data)
+ event_data = data['sentry.interfaces.Exception']
+ self.assertEquals(len(event_data['frames']), 14)
+
+ frame = event_data['frames'][13]
+
+ self.assertTrue('type' in event_data)
+ self.assertEquals(event_data['type'], 'TemplateSyntaxError')
View
3  tests/test_contrib/django/urls.py
@@ -1,5 +1,6 @@
from django.conf.urls.defaults import *
+from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
- #(r'^get_view/$', views.get_view),
+ (r'^example/$', redirect_to, {'url': 'http://www.example.com'}),
)
Please sign in to comment.
Something went wrong with that request. Please try again.