summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-04-11 12:27:25 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-11-21 10:34:25 +0100
commit8f57f25e82f64e338b4cec1fb58fa27f3d432f8f (patch)
tree38613ffd8788ff28e378e4205f8af718ac4a19e3 /ipatests
parent35c3a5f161b1ac3ce9d55371e2abde52455cf403 (diff)
downloadfreeipa-8f57f25e82f64e338b4cec1fb58fa27f3d432f8f.tar.gz
freeipa-8f57f25e82f64e338b4cec1fb58fa27f3d432f8f.tar.xz
freeipa-8f57f25e82f64e338b4cec1fb58fa27f3d432f8f.zip
Add ConcatenatedLazyText object
This object will allow splitting large translatable strings into more pieces, so translators don't have to re-translate the entire text when a small part changes. https://fedorahosted.org/freeipa/ticket/3587
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_ipalib/test_text.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/ipatests/test_ipalib/test_text.py b/ipatests/test_ipalib/test_text.py
index 2a5ff7a3..4d4ce35c 100644
--- a/ipatests/test_ipalib/test_text.py
+++ b/ipatests/test_ipalib/test_text.py
@@ -332,3 +332,49 @@ class test_NGettextFactory(object):
assert ng.plural is plural
assert ng.domain == 'foo'
assert ng.localedir == 'bar'
+
+
+class test_ConcatenatedText(object):
+
+ klass = text.ConcatenatedLazyText
+
+ def test_init(self):
+ lst = ['a', 'b', 'c', 3]
+ inst = self.klass(*lst)
+ assert inst.components == lst
+ assert unicode(inst) == 'abc3'
+
+ def test_repr(self):
+ lazytext = text.Gettext('foo', 'bar', 'baz')
+ inst = self.klass(lazytext)
+ assert repr(inst) == "ConcatenatedLazyText([%r])" % lazytext
+
+ def test_unicode(self):
+ inst = self.klass('[', text.Gettext('green', 'foo', 'bar'), 1, ']')
+ assert unicode(inst) == u'[green1]'
+
+ def test_mod(self):
+ inst = self.klass('[', text.Gettext('%(color)s', 'foo', 'bar'), ']')
+ assert inst % dict(color='red', stuff='junk') == '[red]'
+
+ def test_add(self):
+ inst = (text.Gettext('pale ', 'foo', 'bar') +
+ text.Gettext('blue', 'foo', 'bar'))
+ assert unicode(inst) == 'pale blue'
+
+ inst = (text.Gettext('bright ', 'foo', 'bar') +
+ text.Gettext('pale ', 'foo', 'bar') +
+ text.Gettext('blue', 'foo', 'bar'))
+ assert unicode(inst) == 'bright pale blue'
+
+ inst = text.Gettext('yellow', 'foo', 'bar') + '!'
+ assert unicode(inst) == 'yellow!'
+
+ inst = '!' + text.Gettext('yellow', 'foo', 'bar')
+ assert unicode(inst) == '!yellow'
+
+ inst = '!' + ('!' + text.Gettext('yellow', 'foo', 'bar'))
+ assert unicode(inst) == '!!yellow'
+
+ inst = (text.Gettext('yellow', 'foo', 'bar') + '!') + '!'
+ assert unicode(inst) == 'yellow!!'