def test_proxy_delete_all():
    defaults = {'hello': 'world', 'foo': None}
    proxy = SettingsProxy('test', defaults)
    assert proxy.get_all() == defaults
    proxy.set('hello', 'test')
    assert proxy.get_all() == {'hello': 'test', 'foo': None}
    proxy.delete_all()
    assert proxy.get_all() == defaults
def test_proxy_defaults():
    proxy = SettingsProxy('test', {'hello': 'world', 'foo': None})
    assert proxy.get('hello') == 'world'
    assert proxy.get('foo') is None
    assert proxy.get('foo', 'bar') == 'bar'
    assert not proxy.get_all(True)
    proxy.set('foo', 'bar')
    assert proxy.get_all(True) == {'foo': 'bar'}
    assert proxy.get_all() == {'hello': 'world', 'foo': 'bar'}
def test_proxy_converters_all():
    epoch_dt = datetime(1970, 1, 1, tzinfo=pytz.utc)
    xmas_dt = datetime(2016, 12, 24, 20, tzinfo=pytz.utc)
    newyear_dt = datetime(2017, 1, 2, tzinfo=pytz.utc)
    duration = timedelta(days=2)
    defaults = {
        'epoch': epoch_dt,
        'xmas': None,
        'newyear': None,
        'duration': None
    }
    converters = {
        name: DatetimeConverter if name != 'duration' else TimedeltaConverter
        for name in defaults
    }
    proxy = SettingsProxy('test', defaults, converters=converters)
    proxy.set('xmas', xmas_dt)
    proxy.set_multi({'newyear': newyear_dt, 'duration': duration})
    assert proxy.get_all() == {
        'epoch': epoch_dt,
        'xmas': xmas_dt,
        'newyear': newyear_dt,
        'duration': duration
    }
def test_get_all_acls():
    proxy = SettingsProxy('foo', {'reg': None}, acls={'acl'})
    assert proxy.get_all() == {'reg': None, 'acl': set()}