Merge "Fixes catalog URL formatting to never return None"
This commit is contained in:
commit
b285c89325
@ -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,
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user