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

Side by Side Diff: grit/format/policy_templates/writers/admx_writer_unittest.py

Issue 631223003: Include chromium version number in policy templates (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 """Unittests for grit.format.policy_templates.writers.admx_writer.""" 7 """Unittests for grit.format.policy_templates.writers.admx_writer."""
8 8
9 9
10 import os 10 import os
(...skipping 19 matching lines...) Expand all
30 # Writer configuration. This dictionary contains parameter used by the ADMX 30 # Writer configuration. This dictionary contains parameter used by the ADMX
31 # Writer 31 # Writer
32 config = { 32 config = {
33 'win_group_policy_class': 'TestClass', 33 'win_group_policy_class': 'TestClass',
34 'win_supported_os': 'SUPPORTED_TESTOS', 34 'win_supported_os': 'SUPPORTED_TESTOS',
35 'win_reg_mandatory_key_name': 'Software\\Policies\\Test', 35 'win_reg_mandatory_key_name': 'Software\\Policies\\Test',
36 'win_reg_recommended_key_name': 'Software\\Policies\\Test\\Recommended', 36 'win_reg_recommended_key_name': 'Software\\Policies\\Test\\Recommended',
37 'win_mandatory_category_path': ['test_category'], 37 'win_mandatory_category_path': ['test_category'],
38 'win_recommended_category_path': ['test_recommended_category'], 38 'win_recommended_category_path': ['test_recommended_category'],
39 'admx_namespace': 'ADMXWriter.Test.Namespace', 39 'admx_namespace': 'ADMXWriter.Test.Namespace',
40 'admx_prefix': 'test_prefix' 40 'admx_prefix': 'test_prefix',
41 'build': 'test_product',
41 } 42 }
42 self.writer = admx_writer.GetWriter(config) 43 self.writer = admx_writer.GetWriter(config)
43 self.writer.Init() 44 self.writer.Init()
44 45
45 def _GetPoliciesElement(self, doc): 46 def _GetPoliciesElement(self, doc):
46 node_list = doc.getElementsByTagName('policies') 47 node_list = doc.getElementsByTagName('policies')
47 self.assertTrue(node_list.length == 1) 48 self.assertTrue(node_list.length == 1)
48 return node_list.item(0) 49 return node_list.item(0)
49 50
50 def _GetCategoriesElement(self, doc): 51 def _GetCategoriesElement(self, doc):
(...skipping 24 matching lines...) Expand all
75 ' <categories>\n' 76 ' <categories>\n'
76 ' <category displayName="$(string.test_category)"' 77 ' <category displayName="$(string.test_category)"'
77 ' name="test_category"/>\n' 78 ' name="test_category"/>\n'
78 ' <category displayName="$(string.test_recommended_category)"' 79 ' <category displayName="$(string.test_recommended_category)"'
79 ' name="test_recommended_category"/>\n' 80 ' name="test_recommended_category"/>\n'
80 ' </categories>\n' 81 ' </categories>\n'
81 ' <policies/>\n' 82 ' <policies/>\n'
82 '</policyDefinitions>') 83 '</policyDefinitions>')
83 self.AssertXMLEquals(output, expected_output) 84 self.AssertXMLEquals(output, expected_output)
84 85
86 def testEmptyVersion(self):
87 self.writer.config['version'] = '39.0.0.0'
88 self.writer.BeginTemplate()
89 self.writer.EndTemplate()
90
91 output = self.writer.GetTemplateText()
92 expected_output = (
93 '<?xml version="1.0" ?>\n'
94 '<policyDefinitions revision="1.0" schemaVersion="1.0">\n'
95 ' <!--test_product version: 39.0.0.0-->\n'
96 ' <policyNamespaces>\n'
97 ' <target namespace="ADMXWriter.Test.Namespace"'
98 ' prefix="test_prefix"/>\n'
99 ' <using namespace="Microsoft.Policies.Windows" prefix="windows"/>\n'
100 ' </policyNamespaces>\n'
101 ' <resources minRequiredRevision="1.0"/>\n'
102 ' <supportedOn>\n'
103 ' <definitions>\n'
104 ' <definition displayName="'
105 '$(string.SUPPORTED_TESTOS)" name="SUPPORTED_TESTOS"/>\n'
106 ' </definitions>\n'
107 ' </supportedOn>\n'
108 ' <categories>\n'
109 ' <category displayName="$(string.test_category)"'
110 ' name="test_category"/>\n'
111 ' <category displayName="$(string.test_recommended_category)"'
112 ' name="test_recommended_category"/>\n'
113 ' </categories>\n'
114 ' <policies/>\n'
115 '</policyDefinitions>')
116 self.AssertXMLEquals(output, expected_output)
117
85 def testEmptyPolicyGroup(self): 118 def testEmptyPolicyGroup(self):
86 empty_policy_group = { 119 empty_policy_group = {
87 'name': 'PolicyGroup', 120 'name': 'PolicyGroup',
88 'policies': [] 121 'policies': []
89 } 122 }
90 # Initialize writer to write a policy group. 123 # Initialize writer to write a policy group.
91 self.writer.BeginTemplate() 124 self.writer.BeginTemplate()
92 # Write policy group 125 # Write policy group
93 self.writer.BeginPolicyGroup(empty_policy_group) 126 self.writer.BeginPolicyGroup(empty_policy_group)
94 self.writer.EndPolicyGroup() 127 self.writer.EndPolicyGroup()
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 })) 502 }))
470 self.assertFalse(self.writer.IsPolicySupported({ 503 self.assertFalse(self.writer.IsPolicySupported({
471 'supported_on': [ 504 'supported_on': [
472 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} 505 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']}
473 ] 506 ]
474 })) 507 }))
475 508
476 509
477 if __name__ == '__main__': 510 if __name__ == '__main__':
478 unittest.main() 511 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/admx_writer.py ('k') | grit/format/policy_templates/writers/doc_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698