예제 #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_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'))
예제 #3
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script> <b>bold</b>'
     x = LinkifiedTranslation(localized_string=s)
     assert x.__html__() == (
         '&lt;script&gt;some naughty xss&lt;/script&gt; '
         '&lt;b&gt;bold&lt;/b&gt;')
예제 #4
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;')