OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 '''Unit tests for grit.pseudo''' | |
7 | |
8 import os | |
9 import sys | |
10 if __name__ == '__main__': | |
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
12 | |
13 import unittest | |
14 | |
15 from grit import pseudo | |
16 from grit import tclib | |
17 | |
18 | |
19 class PseudoUnittest(unittest.TestCase): | |
20 def testVowelMapping(self): | |
21 self.failUnless(pseudo.MapVowels('abebibobuby') == | |
22 u'\u00e5b\u00e9b\u00efb\u00f4b\u00fcb\u00fd') | |
23 self.failUnless(pseudo.MapVowels('ABEBIBOBUBY') == | |
24 u'\u00c5B\u00c9B\u00cfB\u00d4B\u00dcB\u00dd') | |
25 | |
26 def testPseudoString(self): | |
27 out = pseudo.PseudoString('hello') | |
28 self.failUnless(out == pseudo.MapVowels(u'hePelloPo', True)) | |
29 | |
30 def testConsecutiveVowels(self): | |
31 out = pseudo.PseudoString("beautiful weather, ain't it?") | |
32 self.failUnless(out == pseudo.MapVowels( | |
33 u"beauPeautiPifuPul weaPeathePer, aiPain't iPit?", 1)) | |
34 | |
35 def testCapitals(self): | |
36 out = pseudo.PseudoString("HOWDIE DOODIE, DR. JONES") | |
37 self.failUnless(out == pseudo.MapVowels( | |
38 u"HOPOWDIEPIE DOOPOODIEPIE, DR. JOPONEPES", 1)) | |
39 | |
40 def testPseudoMessage(self): | |
41 msg = tclib.Message(text='Hello USERNAME, how are you?', | |
42 placeholders=[ | |
43 tclib.Placeholder('USERNAME', '%s', 'Joi')]) | |
44 trans = pseudo.PseudoMessage(msg) | |
45 # TODO(joi) It would be nicer if 'you' -> 'youPou' instead of | |
46 # 'you' -> 'youPyou' and if we handled the silent e in 'are' | |
47 self.failUnless(trans.GetPresentableContent() == | |
48 pseudo.MapVowels( | |
49 u'HePelloPo USERNAME, hoPow aParePe youPyou?', 1)) | |
50 | |
51 | |
52 if __name__ == '__main__': | |
53 unittest.main() | |
OLD | NEW |