danfairs / django-lazysignup

django-lazysignup is a package designed to allow users to interact with a site as if they were authenticated users, but without signing up. At any time, they can convert their temporary user account to a real user account.
BSD 3-Clause "New" or "Revised" License
410 stars 89 forks source link

AssertionError: You need to have the session app intsalled #46

Closed Raemon closed 6 years ago

Raemon commented 9 years ago

This thread (https://github.com/danfairs/django-lazysignup/issues/39) seemed to touch upon this issue, but didn't seem relevant to my exact problem. (Or at least, didn't explain it well enough)

LazyUser has been working fine in production, but when I try to build unit tests surrounding it I get this error:

Traceback (most recent call last):
    File "/Users/raymondarnold/Dropbox/SublimeDocs/Freelance/agora/checkout/tests.py", line 48, in test_begin_payments_displays_two_submit_options_if_not_logged_in
    response = browse(request, page="checkout")
  File "/Users/raymondarnold/Dropbox/SublimeDocs/Freelance/agora/venv/lib/python3.4/site-packages/lazysignup/decorators.py", line 19, in wrapped
    assert hasattr(request, 'session'), ("You need to have the session "
AssertionError: You need to have the session app intsalled```

My impression looking around is that the session app isn't available during unit tests. I'm currently looking for a workaround for this - it looks like I can manually set up the session, but want to make sure I'm getting the data right. Meanwhile, might be helpful to include something about this in the docs.
danfairs commented 8 years ago

Which settings file are you using for your tests? You'll need to make sure django.contrib.sessions is listed in there. Take a look at the included settings.py in lazysignup for an example.

danfairs commented 6 years ago

Closing due to inactivity - please refer to the test settings file for necessary config.