示例#1
0
 def test_allowed_tags(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<a href="http://example.com">bar</a>'
     x = LinkifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://external.url"][rel="nofollow"]')
     assert links[0].text == 'bar'
示例#2
0
 def test_allowed_tags(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<a href="http://example.com">bar</a>'
     x = LinkifiedTranslation(localized_string=s)
     doc = pq(x.__html__())
     links = doc('a[href="http://external.url"][rel="nofollow"]')
     assert links[0].text == 'bar'
示例#3
0
def test_cache_key():
    # Test that we are not taking the db into account when building our
    # cache keys for django-cache-machine. See bug 928881.
    eq_(Translation._cache_key(1, 'default'),
        Translation._cache_key(1, 'slave'))

    # Test that we are using the same cache no matter what Translation class
    # we use.
    eq_(PurifiedTranslation._cache_key(1, 'default'),
        Translation._cache_key(1, 'default'))
    eq_(LinkifiedTranslation._cache_key(1, 'default'),
        Translation._cache_key(1, 'default'))
示例#4
0
def test_cache_key():
    # Test that we are not taking the db into account when building our
    # cache keys for django-cache-machine. See bug 928881.
    eq_(Translation._cache_key(1, 'default'),
        Translation._cache_key(1, 'slave'))

    # Test that we are using the same cache no matter what Translation class
    # we use.
    eq_(PurifiedTranslation._cache_key(1, 'default'),
        Translation._cache_key(1, 'default'))
    eq_(LinkifiedTranslation._cache_key(1, 'default'),
        Translation._cache_key(1, 'default'))
示例#5
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script> <b>bold</b>'
     x = LinkifiedTranslation(localized_string=s)
     eq_(
         x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt; '
         '&lt;b&gt;bold&lt;/b&gt;')
示例#6
0
 def test_allowed_tags(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<a href="http://example.com">bar</a>'
     x = LinkifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<a rel="nofollow" href="http://external.url">bar</a>')
示例#7
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script> <b>bold</b>'
     x = LinkifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         '&lt;script&gt;some naughty xss&lt;/script&gt; '
         '&lt;b&gt;bold&lt;/b&gt;')
示例#8
0
 def test_allowed_tags(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<a href="http://example.com">bar</a>'
     x = LinkifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<a href="http://external.url" rel="nofollow">bar</a>')