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

Side by Side Diff: grit/format/policy_templates/writers/template_writer_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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 '''Unit tests for grit.format.policy_templates.writers.template_writer'''
6
7 import os
8 import sys
9 if __name__ == '__main__':
10 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../..'))
11
12 import unittest
13
14 from grit.format.policy_templates.writers import template_writer
15
16
17 POLICY_DEFS = [
18 {'name': 'zp', 'type': 'string', 'caption': 'a1', 'supported_on': []},
19 {
20 'type': 'group',
21 'caption': 'z_group1_caption',
22 'name': 'group1',
23 'policies': [
24 {'name': 'z0', 'type': 'string', 'supported_on': []},
25 {'name': 'a0', 'type': 'string', 'supported_on': []}
26 ]
27 },
28 {
29 'type': 'group',
30 'caption': 'b_group2_caption',
31 'name': 'group2',
32 'policies': [{'name': 'q', 'type': 'string', 'supported_on': []}],
33 },
34 {'name': 'ap', 'type': 'string', 'caption': 'a2', 'supported_on': []}
35 ]
36
37
38 GROUP_FIRST_SORTED_POLICY_DEFS = [
39 {
40 'type': 'group',
41 'caption': 'b_group2_caption',
42 'name': 'group2',
43 'policies': [{'name': 'q', 'type': 'string', 'supported_on': []}],
44 },
45 {
46 'type': 'group',
47 'caption': 'z_group1_caption',
48 'name': 'group1',
49 'policies': [
50 {'name': 'z0', 'type': 'string', 'supported_on': []},
51 {'name': 'a0', 'type': 'string', 'supported_on': []}
52 ]
53 },
54 {'name': 'ap', 'type': 'string', 'caption': 'a2', 'supported_on': []},
55 {'name': 'zp', 'type': 'string', 'caption': 'a1', 'supported_on': []},
56 ]
57
58
59 IGNORE_GROUPS_SORTED_POLICY_DEFS = [
60 {'name': 'a0', 'type': 'string', 'supported_on': []},
61 {'name': 'ap', 'type': 'string', 'caption': 'a2', 'supported_on': []},
62 {'name': 'q', 'type': 'string', 'supported_on': []},
63 {'name': 'z0', 'type': 'string', 'supported_on': []},
64 {'name': 'zp', 'type': 'string', 'caption': 'a1', 'supported_on': []},
65 ]
66
67
68 class TemplateWriterUnittests(unittest.TestCase):
69 '''Unit tests for templater_writer.py.'''
70
71 def testSortingGroupsFirst(self):
72 tw = template_writer.TemplateWriter(None, None)
73 sorted_list = tw.SortPoliciesGroupsFirst(POLICY_DEFS)
74 self.assertEqual(sorted_list, GROUP_FIRST_SORTED_POLICY_DEFS)
75
76 def testSortingIgnoreGroups(self):
77 tw = template_writer.TemplateWriter(None, None)
78 sorted_list = tw.FlattenGroupsAndSortPolicies(POLICY_DEFS)
79 self.assertEqual(sorted_list, IGNORE_GROUPS_SORTED_POLICY_DEFS)
80
81
82 if __name__ == '__main__':
83 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698