Permalink
Browse files

bug 840118 - errormill, r=Pike

  • Loading branch information...
1 parent 344a82b commit 9f9e293ef99a5c3a67d1545fd585deaad77facb7 @peterbe peterbe committed Feb 25, 2013
Showing with 4,614 additions and 97 deletions.
  1. +3 −63 apps/homepage/tests.py
  2. +0 −19 apps/homepage/views.py
  3. +1 −0 requirements/prod.txt
  4. +1 −12 settings/base.py
  5. +4 −2 settings/local.py-dist
  6. +4 −0 settings_test.py
  7. +0 −1 urls.py
  8. +18 −0 vendor-local/lib/python/raven/__init__.py
  9. +595 −0 vendor-local/lib/python/raven/base.py
  10. +90 −0 vendor-local/lib/python/raven/conf/__init__.py
  11. +59 −0 vendor-local/lib/python/raven/conf/defaults.py
  12. +44 −0 vendor-local/lib/python/raven/context.py
  13. 0 vendor-local/lib/python/raven/contrib/__init__.py
  14. +28 −0 vendor-local/lib/python/raven/contrib/async.py
  15. +82 −0 vendor-local/lib/python/raven/contrib/celery/__init__.py
  16. +10 −0 vendor-local/lib/python/raven/contrib/django/__init__.py
  17. +35 −0 vendor-local/lib/python/raven/contrib/django/celery/__init__.py
  18. +14 −0 vendor-local/lib/python/raven/contrib/django/celery/models.py
  19. +11 −0 vendor-local/lib/python/raven/contrib/django/celery/tasks.py
  20. +163 −0 vendor-local/lib/python/raven/contrib/django/client.py
  21. +32 −0 vendor-local/lib/python/raven/contrib/django/handlers.py
  22. +17 −0 vendor-local/lib/python/raven/contrib/django/logging.py
  23. +60 −0 vendor-local/lib/python/raven/contrib/django/middleware/__init__.py
  24. +26 −0 vendor-local/lib/python/raven/contrib/django/middleware/wsgi.py
  25. +204 −0 vendor-local/lib/python/raven/contrib/django/models.py
  26. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/__init__.py
  27. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/handlers.py
  28. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/middleware/__init__.py
  29. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/middleware/wsgi.py
  30. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/models.py
  31. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/templatetags/__init__.py
  32. +11 −0 vendor-local/lib/python/raven/contrib/django/raven_compat/templatetags/raven.py
  33. +67 −0 vendor-local/lib/python/raven/contrib/django/serializers.py
  34. +7 −0 vendor-local/lib/python/raven/contrib/django/templatetags/__init__.py
  35. +19 −0 vendor-local/lib/python/raven/contrib/django/templatetags/raven.py
  36. +19 −0 vendor-local/lib/python/raven/contrib/django/urls.py
  37. +51 −0 vendor-local/lib/python/raven/contrib/django/utils.py
  38. +107 −0 vendor-local/lib/python/raven/contrib/django/views.py
  39. +114 −0 vendor-local/lib/python/raven/contrib/flask/__init__.py
  40. +24 −0 vendor-local/lib/python/raven/contrib/flask/utils.py
  41. +7 −0 vendor-local/lib/python/raven/contrib/paste.py
  42. +32 −0 vendor-local/lib/python/raven/contrib/pylons/__init__.py
  43. +252 −0 vendor-local/lib/python/raven/contrib/tornado/__init__.py
  44. 0 vendor-local/lib/python/raven/contrib/transports/__init__.py
  45. +9 −0 vendor-local/lib/python/raven/contrib/transports/zeromq/__init__.py
  46. +58 −0 vendor-local/lib/python/raven/contrib/transports/zeromq/raven_zmq.py
  47. +13 −0 vendor-local/lib/python/raven/contrib/transports/zeromq/sample_client.py
  48. +15 −0 vendor-local/lib/python/raven/contrib/transports/zeromq/sample_server.py
  49. +69 −0 vendor-local/lib/python/raven/contrib/zerorpc/__init__.py
  50. +91 −0 vendor-local/lib/python/raven/contrib/zope/__init__.py
  51. +27 −0 vendor-local/lib/python/raven/contrib/zope/component.xml
  52. +148 −0 vendor-local/lib/python/raven/events.py
  53. +7 −0 vendor-local/lib/python/raven/handlers/__init__.py
  54. +81 −0 vendor-local/lib/python/raven/handlers/logbook.py
  55. +156 −0 vendor-local/lib/python/raven/handlers/logging.py
  56. +61 −0 vendor-local/lib/python/raven/middleware.py
  57. +111 −0 vendor-local/lib/python/raven/processors.py
  58. +7 −0 vendor-local/lib/python/raven/scripts/__init__.py
  59. +93 −0 vendor-local/lib/python/raven/scripts/runner.py
  60. +12 −0 vendor-local/lib/python/raven/transport/__init__.py
  61. +314 −0 vendor-local/lib/python/raven/transport/base.py
  62. +21 −0 vendor-local/lib/python/raven/transport/exceptions.py
  63. +68 −0 vendor-local/lib/python/raven/transport/registry.py
  64. +110 −0 vendor-local/lib/python/raven/transport/threaded.py
  65. +118 −0 vendor-local/lib/python/raven/utils/__init__.py
  66. +94 −0 vendor-local/lib/python/raven/utils/encoding.py
  67. +45 −0 vendor-local/lib/python/raven/utils/json.py
  68. +10 −0 vendor-local/lib/python/raven/utils/serializer/__init__.py
  69. +148 −0 vendor-local/lib/python/raven/utils/serializer/base.py
  70. +89 −0 vendor-local/lib/python/raven/utils/serializer/manager.py
  71. +257 −0 vendor-local/lib/python/raven/utils/stacks.py
  72. +12 −0 vendor-local/lib/python/raven/utils/urlparse.py
  73. +93 −0 vendor-local/lib/python/raven/utils/wsgi.py
@@ -4,13 +4,10 @@
import re
import os
-from mock import patch
from test_utils import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings
-from django.http import Http404
from django.test.client import RequestFactory
-from django.core.urlresolvers import Resolver404
from nose.tools import eq_, ok_
from life.models import Locale
from commons.tests.mixins import EmbedsTestCaseMixin
@@ -34,11 +31,6 @@ def setUp(self):
'django.contrib.auth.backends.ModelBackend',
)
- # make sure this is always set to something and iff the mocking of
- # django_arecibo was to fail at least it won't send anything to a real
- # arecibo server
- settings.ARECIBO_SERVER_URL = 'http://arecibo/'
-
settings.L10N_FEED_URL = self._local_feed_url('test_rss20.xml')
def _local_feed_url(self, filename):
@@ -49,56 +41,6 @@ def tearDown(self):
super(HomepageTestCase, self).tearDown()
settings.AUTHENTICATION_BACKENDS = self._original_auth_backends
- def test_handler404(self):
- # import the root urlconf like django does when it starts up
- root_urlconf = __import__(settings.ROOT_URLCONF,
- globals(), locals(), ['urls'], -1)
- # ...so that we can access the 'handler404' defined in there
- par, end = root_urlconf.handler404.rsplit('.', 1)
- # ...which is an importable reference to the real handler404 function
- views = __import__(par, globals(), locals(), [end], -1)
- # ...and finally we the handler404 function at hand
- handler404 = getattr(views, end)
-
- # to call this view function we need a mock request object
- fake_request = RequestFactory().request(**{'wsgi.input': None})
-
- # the reason for first causing an exception to be raised is because
- # the handler404 function is only called by django when an exception
- # has been raised which means sys.exc_info() is something.
- try:
- raise Http404("something bad")
- except Http404:
- # mock the django_arecibo wrapper so it doesn't actually
- # call out on the network
- with patch('django_arecibo.wrapper') as m:
- # do this inside a frame that has a sys.exc_info()
- response = handler404(fake_request)
- eq_(response.status_code, 404)
- ok_('Page not found' in response.content)
- eq_(m.post.call_count, 1)
-
- try:
- # raise an error but this time withou a message
- raise Http404
- except Http404:
- with patch('django_arecibo.wrapper') as m:
- response = handler404(fake_request)
- eq_(response.status_code, 404)
- ok_('Page not found' in response.content)
- eq_(m.post.call_count, 1)
-
- try:
- # Resolver404 is a subclass of Http404 that is raised by django
- # when it can't match a URL to a view
- raise Resolver404("/never/heard/of/")
- except Resolver404:
- with patch('django_arecibo.wrapper') as m:
- response = handler404(fake_request)
- eq_(response.status_code, 404)
- ok_('Page not found' in response.content)
- eq_(m.post.call_count, 0)
-
def test_handler500(self):
# The reason for doing this COMPRESS_DEBUG_TOGGLE "hack" is because
# our 500.html extends "base.html" which uses ``compress`` blocks.
@@ -134,11 +76,9 @@ def test_handler500(self):
raise NameError("sloppy code!")
except NameError:
# do this inside a frame that has a sys.exc_info()
- with patch('django_arecibo.wrapper') as m:
- response = handler500(fake_request)
- eq_(response.status_code, 500)
- ok_('Oops' in response.content)
- eq_(m.post.call_count, 1)
+ response = handler500(fake_request)
+ eq_(response.status_code, 500)
+ ok_('Oops' in response.content)
finally:
# If this was django 1.4 I would do:
# from django.test.utils import override_settings
@@ -18,30 +18,11 @@
from django.views.defaults import page_not_found
from django.core.cache import cache
from django.views.decorators.http import etag
-import django_arecibo.wrapper
from life.models import Locale
-def handler404(request):
- if getattr(settings, 'ARECIBO_SERVER_URL', None):
- # Make a distinction between Http404 and Resolver404.
- # Http404 is an explicity exception raised from within the views which
- # might indicate the wrong usage of arguments to a view for example.
- # Resolver404 is an implicit exception that Django raises when it can't
- # resolve a URL to an appropriate view or handler.
- # We're not interested in sending Arecibo exceptions on URLs like
- # /blablalb/junk/junk
- # but we might be interested in /dashboard?from=20LL-02-31
- exception = sys.exc_info()[0]
- if isinstance(exception, Http404) or exception is Http404:
- django_arecibo.wrapper.post(request, 404)
- return page_not_found(request)
-
-
def handler500(request):
- if getattr(settings, 'ARECIBO_SERVER_URL', None):
- django_arecibo.wrapper.post(request, 500)
# unlike the default django.views.default.server_error view function we
# want one that passes a RequestContext so that we can have 500.html
# template that uses '{% extends "base.html" %}' which depends on various
@@ -6,3 +6,4 @@ python-memcached
versiontools
feedparser==5.1
pytz==2012d
+raven==3.1.16
View
@@ -80,8 +80,6 @@
'commonware.middleware.FrameOptionsHeader',
'commonware.middleware.ScrubRequestOnException',
-
- 'django_arecibo.middleware.AreciboMiddleware',
)
INSTALLED_APPS += (
@@ -90,8 +88,8 @@
# Local apps
'commons',
'nashvegas',
- 'django_arecibo',
'compressor',
+ 'raven.contrib.django.raven_compat',
# Third-party apps
@@ -132,15 +130,6 @@
## Tests
-## Arecibo
-# See http://readthedocs.org/docs/mozweb/en/latest/errors.html
-ARECIBO_PUBLIC_ACCOUNT_NUMBER = "" # not needed behind firewall
-ARECIBO_SERVER_URL = ""
-ARECIBO_USES_CELERY = False
-ARECIBO_SETTINGS = {
- 'EXCLUDED_POST_VARS': ['password',],
-}
-
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
@@ -47,8 +47,10 @@ COMPRESS_ENABLED = False
SESSION_COOKIE_SECURE = False
-# if you want to test the Arecibo
-#ARECIBO_SERVER_URL = "http://amckay-arecibo.khan.mozilla.org/"
+# if you want to test the Sentry (errormill.mozilla.org)
+#RAVEN_CONFIG = {
+# 'dsn': '' # see https://errormill.mozilla.org/
+#}
# Feed for example, to avoid having to do a HTTP call for the feed use:
#L10N_FEED_URL = 'file://' + os.path.abspath('apps/homepage/test_rss20.xml')
View
@@ -23,3 +23,7 @@
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
)
+
+# don't accidentally do anything whilst running tests
+RAVEN_CONFIG = {}
+SENTRY_DSN = None
View
@@ -50,7 +50,6 @@
(r'^admin/', include(admin.site.urls)),
)
-handler404 = 'homepage.views.handler404'
handler500 = 'homepage.views.handler500'
# Usually, you would include this only for DEBUG, but let's keep
@@ -0,0 +1,18 @@
+"""
+raven
+~~~~~
+
+:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
+:license: BSD, see LICENSE for more details.
+"""
+
+__all__ = ('VERSION', 'Client', 'load')
+
+try:
+ VERSION = __import__('pkg_resources') \
+ .get_distribution('raven').version
+except Exception, e:
+ VERSION = 'unknown'
+
+from raven.base import * # NOQA
+from raven.conf import * # NOQA
Oops, something went wrong.

0 comments on commit 9f9e293

Please sign in to comment.