Merge "Fixes catalog URL formatting to never return None"

This commit is contained in:
Jenkins 2014-06-28 07:58:49 +00:00 committed by Gerrit Code Review
commit b285c89325
2 changed files with 7 additions and 4 deletions

View File

@ -37,7 +37,9 @@ def format_url(url, data):
try:
result = url.replace('$(', '%(') % data
except AttributeError:
return None
LOG.error(_('Malformed endpoint - %(url)r is not a string'),
{"url": url})
raise exception.MalformedEndpoint(endpoint=url)
except KeyError as e:
LOG.error(_("Malformed endpoint %(url)s - unknown key %(keyerror)s"),
{"url": url,

View File

@ -46,9 +46,10 @@ class FormatUrlTests(testtools.TestCase):
def test_formatting_a_non_string(self):
def _test(url_template):
expected_url = None
actual_url = core.format_url(url_template, {})
self.assertEqual(actual_url, expected_url)
self.assertRaises(exception.MalformedEndpoint,
core.format_url,
url_template,
{})
_test(None)
_test(object())