Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2546)

Side by Side Diff: grit/gather/muppet_strings_unittest.py

Issue 7994004: Initial source commit to grit-i18n project. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/gather/muppet_strings.py ('k') | grit/gather/policy_json.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 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.gather.muppet_strings'''
7
8 import os
9 import sys
10 if __name__ == '__main__':
11 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
12
13 import unittest
14
15 from grit.gather import muppet_strings
16
17 class MuppetStringsUnittest(unittest.TestCase):
18 def testParsing(self):
19 original = '''<strings><BLA desc="Says hello">hello!</BLA><BINGO>YEEEESSS!!! </BINGO></strings>'''
20 gatherer = muppet_strings.MuppetStrings(original)
21 gatherer.Parse()
22 self.failUnless(len(gatherer.GetCliques()) == 2)
23 self.failUnless(gatherer.Translate('en').replace('\n', '') == original)
24
25 def testEscapingAndLinebreaks(self):
26 original = ('''\
27 <strings>
28 <LINEBREAK desc="Howdie">Hello
29 there
30 how
31 are
32 you?</LINEBREAK> <ESCAPED meaning="bingo">4 &lt; 6</ESCAPED>
33 </strings>''')
34 gatherer = muppet_strings.MuppetStrings(original)
35 gatherer.Parse()
36 self.failUnless(gatherer.GetCliques()[0].translateable)
37 self.failUnless(len(gatherer.GetCliques()) == 2)
38 self.failUnless(gatherer.GetCliques()[0].GetMessage().GetRealContent() ==
39 'Hello\nthere\nhow\nare\nyou?')
40 self.failUnless(gatherer.GetCliques()[0].GetMessage().GetDescription() == 'H owdie')
41 self.failUnless(gatherer.GetCliques()[1].GetMessage().GetRealContent() ==
42 '4 < 6')
43 self.failUnless(gatherer.GetCliques()[1].GetMessage().GetMeaning() == 'bingo ')
44
45 def testPlaceholders(self):
46 original = "<strings><MESSAGE translateable='True'>Hello [![USER]!] how are you? [![HOUR]!]:[![MINUTE]!]</MESSAGE></strings>"
47 gatherer = muppet_strings.MuppetStrings(original)
48 gatherer.Parse()
49 self.failUnless(gatherer.GetCliques()[0].translateable)
50 msg = gatherer.GetCliques()[0].GetMessage()
51 self.failUnless(len(msg.GetPlaceholders()) == 3)
52 ph = msg.GetPlaceholders()[0]
53 self.failUnless(ph.GetOriginal() == '[![USER]!]')
54 self.failUnless(ph.GetPresentation() == 'USER')
55
56 def testTranslateable(self):
57 original = "<strings><BINGO translateable='false'>Yo yo hi there</BINGO></st rings>"
58 gatherer = muppet_strings.MuppetStrings(original)
59 gatherer.Parse()
60 msg = gatherer.GetCliques()[0].GetMessage()
61 self.failUnless(msg.GetRealContent() == "Yo yo hi there")
62 self.failUnless(not gatherer.GetCliques()[0].translateable)
63
64 if __name__ == '__main__':
65 unittest.main()
66
OLDNEW
« no previous file with comments | « grit/gather/muppet_strings.py ('k') | grit/gather/policy_json.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698