2015-09-27 08:04:06 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import tempfile
|
|
|
|
from wakatime.session_cache import SessionCache
|
|
|
|
from . import utils
|
|
|
|
|
|
|
|
|
|
|
|
class SessionCacheTestCase(utils.TestCase):
|
|
|
|
|
2015-09-27 08:52:53 +00:00
|
|
|
def test_can_crud_session(self):
|
2015-09-27 08:04:06 +00:00
|
|
|
with tempfile.NamedTemporaryFile() as fh:
|
|
|
|
db_file = fh.name
|
|
|
|
|
|
|
|
cache = SessionCache()
|
|
|
|
cache.DB_FILE = db_file
|
|
|
|
session = cache.get()
|
|
|
|
session.headers.update({'x-test': 'abc'})
|
|
|
|
cache.save(session)
|
2015-09-27 08:52:53 +00:00
|
|
|
session = cache.get()
|
|
|
|
self.assertEquals(session.headers.get('x-test'), 'abc')
|
|
|
|
cache.delete()
|
|
|
|
session = cache.get()
|
|
|
|
self.assertEquals(session.headers.get('x-test'), None)
|