def describe(*args, **kwargs): text = f'# {alias(*args, **kwargs)}\n' text += f'## Packages in this update:\n' for p in builds(*args, **kwargs): text += f'* {p.nvr}\n' text += f'## Update description:\n{notes(*args, **kwargs)}' return markup(None, text)
def test_markup_escapes(self): """Ensure we correctly parse markdown & escape HTML""" text = ('# this is a header\n' 'this is some **text**\n' '<script>alert("pants")</script>') html = util.markup(None, text) assert html == ( '<div class="markdown"><h1>this is a header</h1>\n' '<p>this is some <strong>text</strong>\n' '<script>alert("pants")</script></p></div>'), html
def test_markup_with_bleach_1(self, clean): """Use mocking to ensure we correctly use the bleach 1 API.""" text = '# this is a header\nthis is some **text**' result = util.markup(None, text) self.assertEqual(result, 'cleaned text') expected_text = ( u'<div class="markdown"><h1>this is a header</h1>\n<p>this is some <strong>text' u'</strong></p></div>') expected_tags = [ "h1", "h2", "h3", "h4", "h5", "h6", "b", "i", "strong", "em", "tt", "p", "br", "span", "div", "blockquote", "code", "hr", "pre", "ul", "ol", "li", "dd", "dt", "img", "a" ] # The bleach 1 API shoudl get these attrs passed. clean.assert_called_once_with( expected_text, tags=expected_tags, attributes=["src", "href", "alt", "title", "class"])