Add test checking url replcmnt of unkn. file

There was no test case checking the behaviour of what happens when
trying to {filename} an unknown file.

Also changed the braces to `'` chars that we use elseware.
This commit is contained in:
derwinlu 2017-01-23 23:54:38 +01:00
commit 22208a9471
2 changed files with 17 additions and 1 deletions

View file

@ -246,7 +246,7 @@ class Content(object):
origin = origin.replace('\\', '/') # for Windows paths.
else:
logger.warning(
"Unable to find `%s`, skipping url replacement.",
"Unable to find '%s', skipping url replacement.",
value.geturl(), extra={
'limit_msg': ("Other resources were not found "
"and their urls not replaced")})

View file

@ -731,3 +731,19 @@ class TestStatic(LoggedTestCase):
msg="Replacement Indicator 'unknown' not recognized, "
"skipping replacement",
level=logging.WARNING)
def test_link_to_unknown_file(self):
"{filename} link to unknown file should trigger warning."
html = '<a href="{filename}foo">link</a>'
page = Page(content=html,
metadata={'title': 'fakepage'}, settings=self.settings,
source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
context=self.context)
content = page.get_content('')
self.assertEqual(content, html)
self.assertLogCountEqual(
count=1,
msg="Unable to find 'foo', skipping url replacement.",
level=logging.WARNING)