本文整理匯總了Python中indico.core.settings.SettingsProxy.set_multi方法的典型用法代碼示例。如果您正苦於以下問題:Python SettingsProxy.set_multi方法的具體用法?Python SettingsProxy.set_multi怎麽用?Python SettingsProxy.set_multi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類indico.core.settings.SettingsProxy
的用法示例。
在下文中一共展示了SettingsProxy.set_multi方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_set_multi_propagate
# 需要導入模塊: from indico.core.settings import SettingsProxy [as 別名]
# 或者: from indico.core.settings.SettingsProxy import set_multi [as 別名]
def test_set_multi_propagate(mocker):
Setting = mocker.patch('indico.core.settings.core.Setting')
SettingPrincipal = mocker.patch('indico.core.settings.core.SettingPrincipal')
proxy = SettingsProxy('foo', {'reg': None}, acls={'acl'})
proxy.set_multi({
'reg': 'bar',
'acl': {'u'}
})
Setting.set_multi.assert_called_once_with('foo', {'reg': 'bar'})
SettingPrincipal.set_acl_multi.assert_called_with('foo', {'acl': {'u'}})
示例2: test_proxy_converters_all
# 需要導入模塊: from indico.core.settings import SettingsProxy [as 別名]
# 或者: from indico.core.settings.SettingsProxy import set_multi [as 別名]
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}