diff options
author | Ashley Camba Garrido <ashwoods@gmail.com> | 2017-09-26 14:11:41 +0200 |
---|---|---|
committer | Ashley Camba <ashwoods@gmail.com> | 2017-09-26 21:16:59 +0200 |
commit | bdaf68c2849d273ef5b60da7e1af33d91ada70ec (patch) | |
tree | eb13c23731480f188068c830a8f7a016dc60af94 | |
parent | e3aad24b7a443e59b824a40bb17cd49593e3b3d3 (diff) | |
download | raven-bdaf68c2849d273ef5b60da7e1af33d91ada70ec.tar.gz |
fix(django): Remove second user_info and fix tests
-rw-r--r-- | raven/contrib/django/client.py | 3 | ||||
-rw-r--r-- | tests/contrib/django/tests.py | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/raven/contrib/django/client.py b/raven/contrib/django/client.py index 7ac20a8..1d84c1a 100644 --- a/raven/contrib/django/client.py +++ b/raven/contrib/django/client.py @@ -143,6 +143,7 @@ class DjangoClient(Client): install_sql_hook() def get_user_info(self, request): + user_info = { 'ip_address': get_client_ip(request.META), } @@ -160,8 +161,6 @@ class DjangoClient(Client): if not authenticated: return user_info - user_info = {} - user_info['id'] = user.pk if hasattr(user, 'email'): diff --git a/tests/contrib/django/tests.py b/tests/contrib/django/tests.py index e76f1f5..22a25c6 100644 --- a/tests/contrib/django/tests.py +++ b/tests/contrib/django/tests.py @@ -231,7 +231,12 @@ class DjangoClientTest(TestCase): assert len(self.raven.events) == 1 event = self.raven.events.pop(0) - assert 'user' not in event + assert 'user' in event + + user_info = event['user'] + assert user_info == { + {'ip_address': '127.0.0.1'} + } assert self.client.login(username='admin', password='password') @@ -249,6 +254,7 @@ class DjangoClientTest(TestCase): @pytest.mark.skipif(not DJANGO_15, reason='< Django 1.5') def test_get_user_info_abstract_user(self): + from django.db import models from django.http import HttpRequest from django.contrib.auth.models import AbstractBaseUser |