def test_internal_link(self):
     s = u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>'
     x = PurifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://addons.mozilla.org/foo"][rel="nofollow"]')
     assert links[0].text == 'bar'
     assert doc('b')[0].text == 'markup'
Beispiel #2
0
 def test_internal_link(self):
     s = u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>'
     x = PurifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://addons.mozilla.org/foo"][rel="nofollow"]')
     assert links[0].text == 'bar'
     assert doc('b')[0].text == 'markup'
Beispiel #3
0
 def test_external_text_link(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<b>markup</b> http://example.com'
     x = PurifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://external.url"][rel="nofollow"]')
     assert links[0].text == 'http://example.com'
     assert doc('b')[0].text == 'markup'
 def test_external_text_link(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<b>markup</b> http://example.com'
     x = PurifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://external.url"][rel="nofollow"]')
     assert links[0].text == 'http://example.com'
     assert doc('b')[0].text == 'markup'
Beispiel #5
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = PurifiedTranslation(localized_string=s)
     assert x.__html__() == '&lt;script&gt;some naughty xss&lt;/script&gt;'
Beispiel #6
0
 def test_allowed_tags(self):
     s = u'<b>bold text</b> or <code>code</code>'
     x = PurifiedTranslation(localized_string=s)
     assert x.__html__() == u'<b>bold text</b> or <code>code</code>'
Beispiel #7
0
 def test_raw_text(self):
     s = u'   This is some text   '
     x = PurifiedTranslation(localized_string=s)
     assert x.__html__() == 'This is some text'
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
 def test_allowed_tags(self):
     s = u'<b>bold text</b> or <code>code</code>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), u'<b>bold text</b> or <code>code</code>')
 def test_raw_text(self):
     s = u'   This is some text   '
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), 'This is some text')