Fix tests to work with Django 1.4.22

The 1.4.22 security fix makes it so that empty sessions are not written.
To keep the tests working, we now log in the user, so that some data is
saved to the session.
This commit is contained in:
Ned Batchelder
2015-08-19 10:38:48 -04:00
parent c3234c1cfc
commit 9f92054ca7

View File

@@ -10,6 +10,8 @@ from django.test.client import Client
from django.test.utils import override_settings
import unittest
from student.tests.factories import UserFactory
# NOTE: We set SESSION_SAVE_EVERY_REQUEST to True in order to make sure
# Sessions are always started on every request
@@ -22,8 +24,13 @@ class MicroSiteSessionCookieTests(TestCase):
def setUp(self):
super(MicroSiteSessionCookieTests, self).setUp()
# create a test client
# Create a test client, and log it in so that it will save some session
# data.
self.user = UserFactory.create()
self.user.set_password('password')
self.user.save()
self.client = Client()
self.client.login(username=self.user.username, password="password")
def test_session_cookie_domain_no_microsite(self):
"""