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:
|
try:
|
||||||
result = url.replace('$(', '%(') % data
|
result = url.replace('$(', '%(') % data
|
||||||
except AttributeError:
|
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:
|
except KeyError as e:
|
||||||
LOG.error(_("Malformed endpoint %(url)s - unknown key %(keyerror)s"),
|
LOG.error(_("Malformed endpoint %(url)s - unknown key %(keyerror)s"),
|
||||||
{"url": url,
|
{"url": url,
|
||||||
|
@ -46,9 +46,10 @@ class FormatUrlTests(testtools.TestCase):
|
|||||||
|
|
||||||
def test_formatting_a_non_string(self):
|
def test_formatting_a_non_string(self):
|
||||||
def _test(url_template):
|
def _test(url_template):
|
||||||
expected_url = None
|
self.assertRaises(exception.MalformedEndpoint,
|
||||||
actual_url = core.format_url(url_template, {})
|
core.format_url,
|
||||||
self.assertEqual(actual_url, expected_url)
|
url_template,
|
||||||
|
{})
|
||||||
|
|
||||||
_test(None)
|
_test(None)
|
||||||
_test(object())
|
_test(object())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user