本文整理匯總了Python中redash.utils.configuration.ConfigurationContainer.update方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigurationContainer.update方法的具體用法?Python ConfigurationContainer.update怎麽用?Python ConfigurationContainer.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redash.utils.configuration.ConfigurationContainer
的用法示例。
在下文中一共展示了ConfigurationContainer.update方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_doesnt_leave_leftovers
# 需要導入模塊: from redash.utils.configuration import ConfigurationContainer [as 別名]
# 或者: from redash.utils.configuration.ConfigurationContainer import update [as 別名]
def test_doesnt_leave_leftovers(self):
container = ConfigurationContainer({'a': 1, 'b': 'test', 'e': 3}, configuration_schema)
new_config = container.to_dict(mask_secrets=True)
new_config.pop('e')
container.update(new_config)
self.assertEqual(container['a'], 1)
self.assertEqual('test', container['b'])
self.assertNotIn('e', container)
示例2: TestConfigurationUpdate
# 需要導入模塊: from redash.utils.configuration import ConfigurationContainer [as 別名]
# 或者: from redash.utils.configuration.ConfigurationContainer import update [as 別名]
class TestConfigurationUpdate(TestCase):
def setUp(self):
self.config = {'a': 1, 'b': 'test'}
self.container = ConfigurationContainer(self.config, configuration_schema)
def test_rejects_invalid_new_config(self):
self.assertRaises(ValidationError, lambda: self.container.update({'c': 3}))
def test_fails_if_no_schema_set(self):
self.container.set_schema(None)
self.assertRaises(RuntimeError, lambda: self.container.update({'c': 3}))
def test_ignores_secret_placehodler(self):
self.container.update(self.container.to_dict(mask_secrets=True))
self.assertEqual(self.container['b'], self.config['b'])
def test_updates_secret(self):
new_config = {'a': 2, 'b': 'new'}
self.container.update(new_config)
self.assertDictEqual(self.container._config, new_config)
def test_doesnt_leave_leftovers(self):
container = ConfigurationContainer({'a': 1, 'b': 'test', 'e': 3}, configuration_schema)
new_config = container.to_dict(mask_secrets=True)
new_config.pop('e')
container.update(new_config)
self.assertEqual(container['a'], 1)
self.assertEqual('test', container['b'])
self.assertNotIn('e', container)
示例3: test_works_for_schema_without_secret
# 需要導入模塊: from redash.utils.configuration import ConfigurationContainer [as 別名]
# 或者: from redash.utils.configuration.ConfigurationContainer import update [as 別名]
def test_works_for_schema_without_secret(self):
secretless = configuration_schema.copy()
secretless.pop('secret')
container = ConfigurationContainer({'a': 1, 'b': 'test', 'e': 3}, secretless)
container.update({'a': 2})
self.assertEqual(container['a'], 2)