summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-08-26 11:51:08 -0700
committerJoffrey F <joffrey@docker.com>2015-08-26 11:51:08 -0700
commite7a9ae097c8e8b32d7f4351693a71f8d1ad7cd2f (patch)
tree2b682a329fe606ade47f334cb771ba024b2006fa
parent9937a31a88b9a5de248bd631cc9eb1a83c48f56f (diff)
downloaddocker-py-e7a9ae097c8e8b32d7f4351693a71f8d1ad7cd2f.tar.gz
Don't remove LogConfig.types shortcut
-rw-r--r--docker/utils/types.py1
-rw-r--r--tests/utils_test.py8
2 files changed, 7 insertions, 2 deletions
diff --git a/docker/utils/types.py b/docker/utils/types.py
index 8271a0d..ea9f06d 100644
--- a/docker/utils/types.py
+++ b/docker/utils/types.py
@@ -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'))
diff --git a/tests/utils_test.py b/tests/utils_test.py
index 433bf07..01a38a8 100644
--- a/tests/utils_test.py
+++ b/tests/utils_test.py
@@ -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(