Improved messaging for simple type validator

English language is a tricky old thing and I've pulled out the validator type
parsing so that we can prefix our validator types with the correct article,
'an' or 'a'.

Doing a bit of extra hard work to ensure the error message is clear and
well constructed english.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-09-08 12:01:47 +01:00
commit 418ec5336b
2 changed files with 50 additions and 6 deletions

View file

@ -269,6 +269,21 @@ class ConfigTest(unittest.TestCase):
)
self.assertEqual(service[0]['entrypoint'], entrypoint)
def test_validation_message_for_invalid_type_when_multiple_types_allowed(self):
expected_error_msg = "Service 'web' configuration key 'mem_limit' contains an invalid type, it should be a number or a string"
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
config.load(
config.ConfigDetails(
{'web': {
'image': 'busybox',
'mem_limit': ['incorrect']
}},
'working_dir',
'filename.yml'
)
)
class InterpolationTest(unittest.TestCase):
@mock.patch.dict(os.environ)