本文整理汇总了Python中mkt.translations.models.Translation类的典型用法代码示例。如果您正苦于以下问题:Python Translation类的具体用法?Python Translation怎么用?Python Translation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Translation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_translation_sequence_increases
def test_translation_sequence_increases(self):
"""Make sure translation sequence increases monotonically."""
newtrans1 = Translation.new('abc', 'en-us')
newtrans1.save()
newtrans2 = Translation.new('def', 'de')
newtrans2.save()
assert newtrans2.pk > newtrans1.pk, (
'Translation sequence needs to keep increasing.')
示例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_empty_translations_seq
def test_empty_translations_seq(self):
"""Make sure we can handle an empty translation sequence table."""
TranslationSequence.objects.all().delete()
newtrans = Translation.new('abc', 'en-us')
newtrans.save()
assert newtrans.id > 0, (
'Empty translation table should still generate an ID.')
示例4: test_single_translation_sequence
def test_single_translation_sequence(self):
"""Make sure we only ever have one translation sequence."""
TranslationSequence.objects.all().delete()
eq_(TranslationSequence.objects.count(), 0)
for i in range(5):
newtrans = Translation.new(str(i), 'en-us')
newtrans.save()
eq_(TranslationSequence.objects.count(), 1)
示例5: test_whitespace
def test_whitespace(self):
t = Translation(localized_string=' khaaaaaan! ', id=999)
t.save()
eq_('khaaaaaan!', t.localized_string)
示例6: test_sorting
def test_sorting(self):
"""Test translation comparisons in Python code."""
b = Translation.new('bbbb', 'de')
a = Translation.new('aaaa', 'de')
c = Translation.new('cccc', 'de')
eq_(sorted([c, a, b]), [a, b, c])