-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtests.py
40 lines (29 loc) · 1.18 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib.sessions.tests import SessionTestsMixin
from django.utils import unittest
conf = getattr(settings, 'REDIS_SESSION_CONFIG', {})
class RedisSessionTests(SessionTestsMixin, unittest.TestCase):
override_config = {
'USE_HASH': False
}
def setUp(self):
test_conf = conf.copy()
test_conf.update(self.override_config)
settings.REDIS_SESSION_CONFIG = test_conf
from redisession.backend import SessionStore
self.backend = SessionStore
self.session = self.backend()
def test_delete(self):
self.session.save()
self.session.delete(self.session.session_key)
self.assertFalse(self.session.exists(self.session.session_key))
if not hasattr(SessionTestsMixin, 'test_session_key_is_read_only'):
def test_session_key_is_read_only(self):
def set_session_key(session):
session.session_key = session._get_new_session_key()
self.assertRaises(AttributeError, set_session_key, self.session)
class RedisHashSessionTests(RedisSessionTests):
override_config = {
'USE_HASH': True
}