models.main: Add a serialilzer to run generate_remote_helpers()
[git-cola.git] / test / test_cola_app.py
blob26e8a4db3cbb6851d1d676a31f695bcdfe02acc6
1 # -*- encoding: utf-8 -*-
2 import unittest
3 from PyQt4 import QtCore
5 import cola.app
6 from cola import version
9 if version.check('pyqt_qrunnable', QtCore.PYQT_VERSION_STR):
10 BaseTestCase = unittest.TestCase
11 else:
12 BaseTestCase = object
15 class ColaApplicationTestCase(BaseTestCase):
16 """Test cases for the ColaApplication class"""
18 def test_translates_noun(self):
19 """Test that strings with @@noun are translated
20 """
21 app = cola.app.ColaApplication([], locale='ja_JP', gui=False)
22 expected = (unichr(0x30b3) + unichr(0x30df) +
23 unichr(0x30c3) + unichr(0x30c8))
24 self.assertEqual(app.translate('??', 'Commit@@noun'), expected)
26 def test_translates_verb(self):
27 """Test that strings with @@verb are translated
28 """
29 app = cola.app.ColaApplication([], locale='de_DE', gui=False)
30 self.assertEqual(app.translate('??', 'Commit@@verb'), 'Eintragen')
32 def test_translates_english_noun(self):
33 """Test that English strings with @@noun are properly handled
34 """
35 app = cola.app.ColaApplication([], locale='en_US.UTF-8', gui=False)
36 self.assertEqual(app.translate('??', 'Commit@@noun'), 'Commit')
38 def test_translates_english_verb(self):
39 """Test that English strings with @@verb are properly handled
40 """
41 app = cola.app.ColaApplication([], locale='en_US.UTF-8', gui=False)
42 self.assertEqual(app.translate('??', 'Commit@@verb'), 'Commit')
44 def test_translates_random_english(self):
45 """Test that random English strings are passed through as-is
46 """
47 app = cola.app.ColaApplication([], locale='en_US.UTF-8', gui=False)
48 self.assertEqual(app.translate('??', 'Random'), 'Random')
50 def test_guards_against_qstring(self):
51 """Test that random English strings are passed through as-is
52 """
53 app = cola.app.ColaApplication([], locale='en_US.UTF-8', gui=False)
54 qstr = QtCore.QString('Random')
55 self.assertEqual(app.translate('??', qstr), 'Random')
58 if __name__ == '__main__':
59 unittest.main()