edx/edx-platform — pull request #108 by e0d (2013-06-07 17:12:50+00:00)
Title: add raise error and tests

We are getting these in production periodically

```
Jun 6 20:30:47 prod-edxapp-007 [service_variant=lms][django.request][env:prod_edx] ERROR [prod-edxapp-007 26287] [base.py:215] - Internal Server Error: /courses/HarvardX/CB22x/2013_Spring/discussion/forum/users/1423155/followed
Traceback (most recent call last):
File "/opt/edx/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/opt/edx/local/lib/python2.7/site-packages/newrelic-1.8.0.13/newrelic/api/object_wrapper.py", line 220, in __call__
self._nr_instance, args, kwargs)
File "/opt/edx/local/lib/python2.7/site-packages/newrelic-1.8.0.13/newrelic/hooks/framework_django.py", line 471, in wrapper
return wrapped(*args, **kwargs)
File "/opt/wwc/edx-platform/lms/djangoapps/django_comment_client/forum/views.py", line 391, in followed_threads
user_info = cc.User.from_django_user(request.user).to_dict()
File "/opt/wwc/edx-platform/lms/lib/comment_client/user.py", line 28, in from_django_user
email=user.email)
File "/opt/edx/local/lib/python2.7/site-packages/django/utils/functional.py", line 185, in inner
return func(self._wrapped, *args)
AttributeError: 'AnonymousUser' object has no attribute 'email'
```

This pull request changes the behavior of User.from_django_user(request.user) to throw an error if it received the wrong type. This will not fix the errors, but will hopefully make the root cause more clear. The call to this method without a real user cannot succeed in a useful way, so raising an error seems appropriate.

Run with

```
rake test_lms[comment_client.tests.tests:CommentClientTest]git status
```