mirror of https://github.com/docker/docker-py.git
Don't remove LogConfig.types shortcut
This commit is contained in:
parent
9937a31a88
commit
e7a9ae097c
|
@ -20,6 +20,7 @@ class DictType(dict):
|
||||||
|
|
||||||
|
|
||||||
class LogConfig(DictType):
|
class LogConfig(DictType):
|
||||||
|
types = LogConfigTypesEnum
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
log_driver_type = kwargs.get('type', kwargs.get('Type'))
|
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'))
|
self.assertRaises(ValueError, lambda: Ulimit(name='hello', hard='456'))
|
||||||
|
|
||||||
def test_create_host_config_dict_logconfig(self):
|
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)
|
config = create_host_config(log_config=dct)
|
||||||
self.assertIn('LogConfig', config)
|
self.assertIn('LogConfig', config)
|
||||||
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
|
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
|
||||||
self.assertEqual(dct['type'], config['LogConfig'].type)
|
self.assertEqual(dct['type'], config['LogConfig'].type)
|
||||||
|
|
||||||
def test_create_host_config_obj_logconfig(self):
|
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)
|
config = create_host_config(log_config=obj)
|
||||||
self.assertIn('LogConfig', config)
|
self.assertIn('LogConfig', config)
|
||||||
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
|
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
|
||||||
self.assertEqual(obj, config['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):
|
def test_resolve_repository_name(self):
|
||||||
# docker hub library image
|
# docker hub library image
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
Loading…
Reference in New Issue