Skip to content

Instantly share code, notes, and snippets.

@arq101
Created November 1, 2015 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arq101/62823fad1f2778a14f33 to your computer and use it in GitHub Desktop.
Save arq101/62823fad1f2778a14f33 to your computer and use it in GitHub Desktop.
ipdb> ll
83 def test_register_existing_email_shows_email_already_exists(self):
84 existing_user = get(EmoovUser)
85
86 import ipdb; ipdb.set_trace()
87
88 user_obj = new(EmoovUser)
89 data = {
90 'email': existing_user.email,
91 'password': user_obj.password,
92 'salutation': user_obj.salutation,
93 'first_name': user_obj.first_name,
94 'last_name': user_obj.last_name,
95 'primary_phone': '0123456789',
96 }
97
---> 98 response = self.client.post('/auth/register', format='json', data=data)
# now if I user an existing email which this unittest is testing for, I get the KeyError ...
ipdb> data['email']
u'a1@dynamicfixture.com'
ipdb> self.client.post('/auth/register', format='json', data=data)
ERROR 2015-11-01 15:24:45,128 base Internal Server Error: /auth/register
Traceback (most recent call last):
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 213, in dispatch
response = self.handle_exception(exc)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 210, in dispatch
self.check_user_and_send_email(response, request)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 226, in check_user_and_send_email
response.data['salutation']['display_name'] + " " +
KeyError: 'salutation'
ERROR 2015-11-01 15:24:45,128 base Internal Server Error: /auth/register
Traceback (most recent call last):
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/arqeeb/.virtualenvs/hoth/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 213, in dispatch
response = self.handle_exception(exc)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 210, in dispatch
self.check_user_and_send_email(response, request)
File "/Users/arqeeb/Github/hoth/accounts/views.py", line 226, in check_user_and_send_email
response.data['salutation']['display_name'] + " " +
KeyError: 'salutation'
*** KeyError: 'salutation'
# however if a non existing email address is used to register, it has no problems obviously.
ipdb> data['email'] = 'darkman@forsight.com'
ipdb> data
{'first_name': u'2', 'last_name': u'2', 'primary_phone': '0123456789', 'salutation': 1, 'password': u'2', 'email': 'darkman@forsight.com'}
ipdb> self.client.post('/auth/register', format='json', data=data)
<rest_framework.response.Response object at 0x10d2315d0>
# I think when it checks for an existing email address upon registration, it needs better handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment