本文整理匯總了Python中mkt.translations.models.PurifiedTranslation類的典型用法代碼示例。如果您正苦於以下問題:Python PurifiedTranslation類的具體用法?Python PurifiedTranslation怎麽用?Python PurifiedTranslation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PurifiedTranslation類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_external_text_link
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)
eq_(x.__html__(),
u'<b>markup</b> <a rel="nofollow" '
u'href="http://external.url">http://example.com</a>')
示例2: test_cache_key
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: test_internal_link
def test_internal_link(self):
s = u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>'
x = PurifiedTranslation(localized_string=s)
eq_(x.__html__(),
u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>')
示例4: test_forbidden_tags
def test_forbidden_tags(self):
s = u'<script>some naughty xss</script>'
x = PurifiedTranslation(localized_string=s)
eq_(x.__html__(), '<script>some naughty xss</script>')
示例5: test_allowed_tags
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>')
示例6: test_raw_text
def test_raw_text(self):
s = u' This is some text '
x = PurifiedTranslation(localized_string=s)
eq_(x.__html__(), 'This is some text')
示例7: test_external_text_link
def test_external_text_link(self):
s = u'<b>markup</b> http://example.com'
x = PurifiedTranslation(localized_string=s)
eq_(x.__html__(),
u'<b>markup</b> '
u'<a href="http://example.com">http://example.com</a>')