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'
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'))
def test_forbidden_tags(self): s = u'<script>some naughty xss</script> <b>bold</b>' x = LinkifiedTranslation(localized_string=s) eq_( x.__html__(), '<script>some naughty xss</script> ' '<b>bold</b>')
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>')
def test_forbidden_tags(self): s = u'<script>some naughty xss</script> <b>bold</b>' x = LinkifiedTranslation(localized_string=s) eq_(x.__html__(), '<script>some naughty xss</script> ' '<b>bold</b>')
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>')