Exemplo n.º 1
0
 def test_openclose_tag(self, tag):
     raw_body = "<{tag}>some text</{tag}>".format(tag=tag)
     is_inline_tag = tag in [
         "b", "code", "del", "em", "i", "kbd", "s", "sup", "sub", "strong",
         "strike"
     ]
     rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body
     self.assertEqual(render_body(raw_body), rendered_body)
Exemplo n.º 2
0
 def test_selfclosing_tag(self, tag):
     raw_body = "<{tag}>".format(tag=tag)
     is_inline_tag = tag == "br"
     rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body
     self.assertEqual(render_body(raw_body), rendered_body)
Exemplo n.º 3
0
 def test_openclose_tag(self, tag):
     raw_body = "<{tag}>some text</{tag}>".format(tag=tag)
     is_inline_tag = tag in ["b", "code", "del", "em", "i", "kbd", "s", "sup", "sub", "strong", "strike"]
     rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body
     self.assertEqual(render_body(raw_body), rendered_body)
Exemplo n.º 4
0
 def test_markdown_inline(self, delimiter, tag):
     self.assertEqual(
         render_body(
             "{delimiter}some text{delimiter}".format(delimiter=delimiter)),
         "<p><{tag}>some text</{tag}></p>".format(tag=tag))
Exemplo n.º 5
0
 def get_rendered_body(self, obj):
     """Returns the rendered body content."""
     return render_body(obj["body"])
Exemplo n.º 6
0
 def test_unpaired_end_tag(self):
     self.assertEqual(render_body("foo</i>bar"), "<p>foobar</p>")
Exemplo n.º 7
0
 def test_script_tag(self):
     raw_body = '<script type="text/javascript">alert("evil script");</script>'
     self.assertEqual(render_body(raw_body), 'alert("evil script");')
Exemplo n.º 8
0
 def test_allowed_img_tag(self, protocol):
     raw_body = '<img src="{protocol}://foo" width="111" height="222" alt="bar" title="baz">'.format(
         protocol=protocol
     )
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 9
0
 def test_script_tag(self):
     raw_body = '<script type="text/javascript">alert("evil script");</script>'
     self.assertEqual(render_body(raw_body), 'alert("evil script");')
Exemplo n.º 10
0
 def test_disallowed_img_tag(self):
     raw_body = '<img src="gopher://foo">'
     self.assertEqual(render_body(raw_body), "<p></p>")
Exemplo n.º 11
0
 def test_allowed_img_tag(self, protocol):
     raw_body = '<img src="{protocol}://foo" width="111" height="222" alt="bar" title="baz">'.format(
         protocol=protocol)
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 12
0
 def test_disallowed_a_tag(self):
     raw_body = '<a href="gopher://foo">link content</a>'
     self.assertEqual(render_body(raw_body), "<p>link content</p>")
Exemplo n.º 13
0
 def test_allowed_a_tag(self, protocol):
     raw_body = '<a href="{protocol}://foo" title="bar">baz</a>'.format(
         protocol=protocol)
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 14
0
 def test_selfclosing_tag(self, tag):
     raw_body = "<{tag}>".format(tag=tag)
     is_inline_tag = tag == "br"
     rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body
     self.assertEqual(render_body(raw_body), rendered_body)
Exemplo n.º 15
0
 def test_allowed_a_tag(self, protocol):
     raw_body = '<a href="{protocol}://foo" title="bar">baz</a>'.format(protocol=protocol)
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 16
0
 def test_allowed_unpaired_tags(self, tag):
     raw_body = "foo<{tag}>bar".format(tag=tag)
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 17
0
 def test_disallowed_a_tag(self):
     raw_body = '<a href="gopher://foo">link content</a>'
     self.assertEqual(render_body(raw_body), "<p>link content</p>")
Exemplo n.º 18
0
 def test_unpaired_end_tag(self):
     self.assertEqual(render_body("foo</i>bar"), "<p>foobar</p>")
Exemplo n.º 19
0
 def test_disallowed_img_tag(self):
     raw_body = '<img src="gopher://foo">'
     self.assertEqual(render_body(raw_body), "<p></p>")
Exemplo n.º 20
0
 def test_interleaved_tags(self):
     self.assertEqual(render_body("foo<i>bar<b>baz</i>quux</b>greg"),
                      "<p>foo<i>barbaz</i>quuxgreg</p>")
Exemplo n.º 21
0
 def test_allowed_unpaired_tags(self, tag):
     raw_body = "foo<{tag}>bar".format(tag=tag)
     self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))
Exemplo n.º 22
0
 def test_empty(self):
     self.assertEqual(render_body(""), "")
Exemplo n.º 23
0
 def test_interleaved_tags(self):
     self.assertEqual(
         render_body("foo<i>bar<b>baz</i>quux</b>greg"),
         "<p>foo<i>barbaz</i>quuxgreg</p>"
     )
Exemplo n.º 24
0
 def test_markdown_inline(self, delimiter, tag):
     self.assertEqual(
         render_body("{delimiter}some text{delimiter}".format(delimiter=delimiter)),
         "<p><{tag}>some text</{tag}></p>".format(tag=tag)
     )
Exemplo n.º 25
0
 def get_rendered_body(self, obj):
     """Returns the rendered body content."""
     return render_body(obj["body"])
Exemplo n.º 26
0
 def test_empty(self):
     self.assertEqual(render_body(""), "")