Recent Issues
|
Sign in
with your
Google
Account to create issues and add comments
Issue 62:
CPO support for previous messages
Unified Diff
File: translate/storage/test_cpo.py
Patch Set:
Jump to:
Index: translate/storage/test_cpo.py
===================================================================
--- translate/storage/test_cpo.py (revision 7740)
+++ translate/storage/test_cpo.py (working copy)
@@ -72,6 +72,62 @@
unit.addnote("# Double commented comment")
assert unit.getnotes() == "# Double commented comment"
+ def test_previous_source(self):
+ """tests if we handle previous msgid properly"""
+ unit = self.UnitClass("Cat")
+ assert unit.prev_source == ""
+
+ unit.prev_source = "Feline"
+ assert unit.prev_source == "Feline"
+
+ unit.prev_source = ""
+ assert unit.prev_source == ""
+
+ def test_previous_context(self):
+ """tests if we handle previous context messages properly"""
+ unit = self.UnitClass("Cat")
+ assert unit.prev_context == ""
+
+ context = "A sort of a cute animal"
+ unit.prev_context = context
+ assert unit.prev_context == context
+
+ unit.prev_context = ""
+ assert unit.prev_context == ""
+
+ def test_previous_plural(self):
+ """tests if we handle previous plural properly"""
+ unit = self.UnitClass("Cat")
+ assert unit.prev_plural == ""
+
+ unit.prev_plural = "Cats"
+ assert unit.prev_plural == "Cats"
+
+ unit.prev_plural = ""
+ assert unit.prev_plural == ""
+
+ def test_set_as_previous(self):
+ """tests if we set previous messages properly"""
+ # This is just a sanity test, for a more complete test look
+ # at convert/test_pot2po.py
+ unit = self.UnitClass("Test %d")
+ unit.msgid_plural = ["Tests %d"]
+ unit.target = ["Teste %d", "Testes %d"]
+ unit.set_as_previous()
+ unit.source = "Test %s"
+ test_unit = '''#, fuzzy\n#| msgid "Test %d"\n#| msgid_plural "Tests %d"
+msgid "Test %s"\nmsgstr "Teste %d"\n'''
+ assert str(unit) == test_unit
+ assert unit.isfuzzy()
+
+ # without a target, the unit remain the same
+ unit2 = self.UnitClass("Other")
+ unit2.msgid_plural = ["Others"]
+ expected = str(unit2)
+ unit2.set_as_previous()
+ assert str(unit2) == expected
+
+
class TestCPOFile(test_po.TestPOFile):
StoreClass = cpo.pofile
def test_msgidcomments(self):