Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit bdaf68c

Browse files
committed
fix(django): Remove second user_info and fix tests
1 parent e3aad24 commit bdaf68c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

raven/contrib/django/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def install_sql_hook(self):
143143
install_sql_hook()
144144

145145
def get_user_info(self, request):
146+
146147
user_info = {
147148
'ip_address': get_client_ip(request.META),
148149
}
@@ -160,8 +161,6 @@ def get_user_info(self, request):
160161
if not authenticated:
161162
return user_info
162163

163-
user_info = {}
164-
165164
user_info['id'] = user.pk
166165

167166
if hasattr(user, 'email'):

tests/contrib/django/tests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ def test_user_info(self):
231231

232232
assert len(self.raven.events) == 1
233233
event = self.raven.events.pop(0)
234-
assert 'user' not in event
234+
assert 'user' in event
235+
236+
user_info = event['user']
237+
assert user_info == {
238+
{'ip_address': '127.0.0.1'}
239+
}
235240

236241
assert self.client.login(username='admin', password='password')
237242

@@ -249,6 +254,7 @@ def test_user_info(self):
249254

250255
@pytest.mark.skipif(not DJANGO_15, reason='< Django 1.5')
251256
def test_get_user_info_abstract_user(self):
257+
252258
from django.db import models
253259
from django.http import HttpRequest
254260
from django.contrib.auth.models import AbstractBaseUser

0 commit comments

Comments
 (0)