2013-08-27 09:46:52 +02:00
|
|
|
import autopath
|
|
|
|
#from py.test import raises
|
|
|
|
|
|
|
|
from tiramisu.config import Config
|
|
|
|
from tiramisu.option import BoolOption, OptionDescription
|
|
|
|
|
|
|
|
|
|
|
|
def test_non_persistent():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
Config(o, session_id='test_non_persistent')
|
|
|
|
|
|
|
|
|
|
|
|
def test_list():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o, session_id='test_non_persistent')
|
|
|
|
from tiramisu.setting import list_sessions
|
|
|
|
assert 'test_non_persistent' in list_sessions()
|
|
|
|
del(c)
|
|
|
|
assert 'test_non_persistent' not in list_sessions()
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_persistent():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
try:
|
|
|
|
Config(o, session_id='test_persistent', persistent=True)
|
|
|
|
except ValueError:
|
|
|
|
# storage is not persistent
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_sessions_persistent():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
try:
|
|
|
|
Config(o, session_id='test_persistent', persistent=True)
|
|
|
|
except ValueError:
|
|
|
|
# storage is not persistent
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
from tiramisu.setting import list_sessions
|
|
|
|
assert 'test_persistent' in list_sessions()
|
|
|
|
|
|
|
|
|
|
|
|
def test_delete_session_persistent():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
try:
|
|
|
|
Config(o, session_id='test_persistent', persistent=True)
|
|
|
|
except ValueError:
|
|
|
|
# storage is not persistent
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
from tiramisu.setting import list_sessions, delete_session
|
2013-08-27 11:39:32 +02:00
|
|
|
assert 'test_persistent' in list_sessions()
|
2013-08-27 09:46:52 +02:00
|
|
|
delete_session('test_persistent')
|
2013-08-27 11:39:32 +02:00
|
|
|
assert 'test_persistent' not in list_sessions()
|
2013-08-27 09:46:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_create_persistent_retrieve():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
try:
|
|
|
|
c = Config(o, session_id='test_persistent', persistent=True)
|
|
|
|
except ValueError:
|
|
|
|
# storage is not persistent
|
|
|
|
pass
|
|
|
|
else:
|
2013-08-27 11:39:32 +02:00
|
|
|
assert c.b is None
|
2013-08-27 09:46:52 +02:00
|
|
|
c.b = True
|
|
|
|
assert c.b is True
|
|
|
|
del(c)
|
|
|
|
c = Config(o, session_id='test_persistent', persistent=True)
|
|
|
|
assert c.b is True
|
|
|
|
from tiramisu.setting import list_sessions, delete_session
|
2013-08-27 11:39:32 +02:00
|
|
|
assert 'test_persistent' in list_sessions()
|
2013-08-27 09:46:52 +02:00
|
|
|
delete_session('test_persistent')
|
|
|
|
c = Config(o, session_id='test_persistent', persistent=True)
|
2013-08-27 11:39:32 +02:00
|
|
|
assert c.b is None
|