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.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 -*-
|
||||
import time
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test import Client as HttpClient
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management import call_command
|
||||
|
@ -32,11 +32,11 @@ class ViewsTestCase(TestCase):
|
|||
page = self.c.get('/')
|
||||
self.assertEqual(page.url, '/dashboard/')
|
||||
|
||||
@override_settings(ROLLING_SESSION_REFRESH=1)
|
||||
def test_rolling_sessions(self):
|
||||
self.c.get('/')
|
||||
session1 = str(self.c.cookies['sessionid'])
|
||||
# Sleep longer than ROLLING_SESSION_REFRESH in our
|
||||
# settings module, to test we get a new session.
|
||||
# Sleep longer than ROLLING_SESSION_REFRESH.
|
||||
time.sleep(2)
|
||||
self.c.get('/')
|
||||
session2 = str(self.c.cookies['sessionid'])
|
||||
|
|
Loading…
Reference in New Issue