def test_set_enum(): class Useless(int, Enum): thing = 1337 Setting.set_multi('foo', {'foo': Useless.thing}) Setting.set('foo', 'bar', Useless.thing) for key in {'foo', 'bar'}: value = Setting.get('foo', key) assert value == Useless.thing assert value == Useless.thing.value assert not isinstance(value, Useless) # we store it as a plain value!
def test_settings3(db): data = {'a': 123, 'b': 'xyz'} Setting.set_multi('test', data) db.session.commit() # automatically converted to a flush assert Setting.get_all('test') == data