Skip to content

Commit bf731f6

Browse files
committed
Brought the rest of the Django client tests up to passing
1 parent 1685490 commit bf731f6

File tree

9 files changed

+183
-226
lines changed

9 files changed

+183
-226
lines changed

runtests.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from os.path import dirname, abspath, join
55
from optparse import OptionParser
66

7-
sys.path.insert(0, dirname(abspath(__file__)))
7+
where_am_i = dirname(abspath(__file__))
8+
9+
sys.path.insert(0, where_am_i)
810

911
logging.getLogger('sentry').addHandler(logging.StreamHandler())
1012

@@ -45,6 +47,7 @@
4547
BROKER_VHOST="/",
4648
CELERY_ALWAYS_EAGER=True,
4749
TEMPLATE_DEBUG=True,
50+
TEMPLATE_DIRS=[join(where_am_i, 'tests', 'contrib', 'django', 'templates')],
4851
)
4952
import djcelery
5053
djcelery.setup_loader()

sentry_client/base.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def process(self, **kwargs):
4848
kwargs.setdefault('level', logging.ERROR)
4949
kwargs.setdefault('server_name', settings.NAME)
5050

51-
versions = get_versions()
51+
modules = settings.INCLUDE_PATHS
52+
53+
versions = get_versions(modules)
5254
kwargs['data']['__sentry__']['versions'] = versions
5355

5456
# Shorten lists/strings
@@ -59,9 +61,6 @@ def process(self, **kwargs):
5961

6062
# if we've passed frames, lets try to fetch the culprit
6163
if not kwargs.get('view') and kwargs['data']['__sentry__'].get('frames'):
62-
# This should be cached
63-
modules = settings.INCLUDE_PATHS
64-
6564
# We iterate through each frame looking for an app in INSTALLED_APPS
6665
# When one is found, we mark it as last "best guess" (best_guess) and then
6766
# check it against SENTRY_EXCLUDE_PATHS. If it isnt listed, then we
@@ -104,7 +103,7 @@ def process(self, **kwargs):
104103
})
105104

106105
if 'checksum' not in kwargs:
107-
checksum = construct_checksum(**kwargs)
106+
kwargs['checksum'] = checksum = construct_checksum(**kwargs)
108107
else:
109108
checksum = kwargs['checksum']
110109

sentry_client/contrib/django/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def process(self, **kwargs):
2929
else:
3030
post_data = request.POST
3131

32+
if 'data' not in kwargs:
33+
kwargs['data'] = {}
34+
3235
kwargs['data'].update(dict(
3336
META=request.META,
3437
POST=post_data,
@@ -77,6 +80,9 @@ def create_from_exception(self, exc_info=None, **kwargs):
7780

7881
data = kwargs.pop('data', {}) or {}
7982

83+
if '__sentry__' not in data:
84+
data['__sentry__'] = {}
85+
8086
try:
8187
exc_type, exc_value, exc_traceback = exc_info
8288

sentry_client/contrib/django/middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SentryResponseErrorIdMiddleware(object):
3333
def process_response(self, request, response):
3434
if not getattr(request, 'sentry', None):
3535
return response
36-
response['X-Sentry-ID'] = request.sentry['id']
36+
response['X-Sentry-ID'] = '$'.join(request.sentry['id'])
3737
return response
3838

3939
class SentryLogMiddleware(object):

sentry_client/utils/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ def get_versions(module_list=None):
6969
versions = {}
7070
for module_name in ext_module_list:
7171
if module_name not in _VERSION_CACHE:
72-
__import__(module_name)
72+
try:
73+
__import__(module_name)
74+
except ImportError:
75+
continue
7376
app = sys.modules[module_name]
7477
if hasattr(app, 'get_version'):
7578
get_version = app.get_version
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% invalid template tag %}

0 commit comments

Comments
 (0)