test importation/exportation with persistent storage

This commit is contained in:
Emmanuel Garette 2018-09-12 21:05:56 +02:00
parent cd7977eae6
commit 5bc81f3749

View File

@ -300,3 +300,31 @@ def test_two_different_information():
delete_session('test_persistent')
delete_session('test_persistent2')
def test_exportation_importation():
b = BoolOption('b', '')
o = OptionDescription('od', '', [b])
try:
c = Config(o, session_id='test_persistent', persistent=True)
d = Config(o, session_id='test_persistent2', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
assert c.option('b').value.get() is None
c.option('b').value.set(True)
assert c.option('b').value.get() is True
del c
#
c = Config(o, session_id='test_persistent', persistent=True)
assert c.value.exportation() == [['b'], [None], [True], ['user']]
d.value.importation(c.value.exportation())
assert c.value.exportation() == [['b'], [None], [True], ['user']]
assert d.value.exportation() == [['b'], [None], [True], ['user']]
del d
#
d = Config(o, session_id='test_persistent2', persistent=True)
assert d.value.exportation() == [['b'], [None], [True], ['user']]
delete_session('test_persistent')
delete_session('test_persistent2')