當前位置: 首頁>>代碼示例>>Python>>正文


Python models.PurifiedTranslation類代碼示例

本文整理匯總了Python中olympia.translations.models.PurifiedTranslation的典型用法代碼示例。如果您正苦於以下問題:Python PurifiedTranslation類的具體用法?Python PurifiedTranslation怎麽用?Python PurifiedTranslation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PurifiedTranslation類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: 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)
     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'
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:7,代碼來源:test_models.py

示例2: 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)
     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'
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:8,代碼來源:test_models.py

示例3: 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'))
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:12,代碼來源:test_models.py

示例4: test_forbidden_tags

 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;')
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:4,代碼來源:test_models.py

示例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>')
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:4,代碼來源:test_models.py

示例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')
開發者ID:Mritrocker96,項目名稱:addons-server,代碼行數:4,代碼來源:test_models.py


注:本文中的olympia.translations.models.PurifiedTranslation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。