Kaydet (Commit) e7a9ae09 authored tarafından Joffrey F's avatar Joffrey F

Don't remove LogConfig.types shortcut

üst 9937a31a
......@@ -20,6 +20,7 @@ class DictType(dict):
class LogConfig(DictType):
types = LogConfigTypesEnum
def __init__(self, **kwargs):
log_driver_type = kwargs.get('type', kwargs.get('Type'))
......
......@@ -192,19 +192,23 @@ class UtilsTest(base.BaseTestCase):
self.assertRaises(ValueError, lambda: Ulimit(name='hello', hard='456'))
def test_create_host_config_dict_logconfig(self):
dct = {'type': 'syslog', 'config': {'key1': 'val1'}}
dct = {'type': LogConfig.types.SYSLOG, 'config': {'key1': 'val1'}}
config = create_host_config(log_config=dct)
self.assertIn('LogConfig', config)
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
self.assertEqual(dct['type'], config['LogConfig'].type)
def test_create_host_config_obj_logconfig(self):
obj = LogConfig(type='syslog', config={'key1': 'val1'})
obj = LogConfig(type=LogConfig.types.SYSLOG, config={'key1': 'val1'})
config = create_host_config(log_config=obj)
self.assertIn('LogConfig', config)
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
self.assertEqual(obj, config['LogConfig'])
def test_logconfig_invalid_config_type(self):
with pytest.raises(ValueError):
LogConfig(type=LogConfig.types.JSON, config='helloworld')
def test_resolve_repository_name(self):
# docker hub library image
self.assertEqual(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment