mirror of https://github.com/snachodog/mybuddy.git
Use settings override for rolling session refresh test
This commit is contained in:
parent
4e7d54163f
commit
3135d1d9d0
|
@ -24,9 +24,3 @@ REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = (
|
||||||
'rest_framework.renderers.JSONRenderer',
|
'rest_framework.renderers.JSONRenderer',
|
||||||
'rest_framework.renderers.BrowsableAPIRenderer',
|
'rest_framework.renderers.BrowsableAPIRenderer',
|
||||||
)
|
)
|
||||||
|
|
||||||
# Session configuration
|
|
||||||
# Used by RollingSessionMiddleware to determine how often to reset the session.
|
|
||||||
# See https://docs.djangoproject.com/en/3.0/topics/http/sessions/
|
|
||||||
|
|
||||||
ROLLING_SESSION_REFRESH = 1
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase, override_settings
|
||||||
from django.test import Client as HttpClient
|
from django.test import Client as HttpClient
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
@ -32,11 +32,11 @@ class ViewsTestCase(TestCase):
|
||||||
page = self.c.get('/')
|
page = self.c.get('/')
|
||||||
self.assertEqual(page.url, '/dashboard/')
|
self.assertEqual(page.url, '/dashboard/')
|
||||||
|
|
||||||
|
@override_settings(ROLLING_SESSION_REFRESH=1)
|
||||||
def test_rolling_sessions(self):
|
def test_rolling_sessions(self):
|
||||||
self.c.get('/')
|
self.c.get('/')
|
||||||
session1 = str(self.c.cookies['sessionid'])
|
session1 = str(self.c.cookies['sessionid'])
|
||||||
# Sleep longer than ROLLING_SESSION_REFRESH in our
|
# Sleep longer than ROLLING_SESSION_REFRESH.
|
||||||
# settings module, to test we get a new session.
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.c.get('/')
|
self.c.get('/')
|
||||||
session2 = str(self.c.cookies['sessionid'])
|
session2 = str(self.c.cookies['sessionid'])
|
||||||
|
|
Loading…
Reference in New Issue