Retrieve sub property keys

The validation message was confusing by displaying only 1 level of
property of the service, even if the error was another level down.

Eg. if the 'files' property of 'extends' was the incorrect format,
it was displaying 'an invalid value for 'extends'', rather than
correctly retrieving 'files'.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-08-10 16:18:21 +01:00
commit e0675b50c0
2 changed files with 28 additions and 7 deletions

View file

@ -124,7 +124,7 @@ class ConfigTest(unittest.TestCase):
)
def test_invalid_config_type_should_be_an_array(self):
expected_error_msg = "Service 'foo' has an invalid value for 'links', it should be an array"
expected_error_msg = "Service 'foo' configuration key 'links' contains an invalid type, it should be an array"
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
config.load(
config.ConfigDetails(
@ -690,6 +690,25 @@ class ExtendsTest(unittest.TestCase):
)
)
def test_extends_validation_sub_property_key(self):
expected_error_msg = "Service 'web' configuration key 'extends' 'file' contains an invalid type"
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
config.load(
config.ConfigDetails(
{
'web': {
'image': 'busybox',
'extends': {
'file': 1,
'service': 'web',
}
},
},
'tests/fixtures/extends',
'filename.yml'
)
)
def test_extends_validation_no_file_key_no_filename_set(self):
dictionary = {'extends': {'service': 'web'}}