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

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

Issue 227073006: Added a policy writer for iOS Plists. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: rebase Created 6 years, 8 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
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 '''Unit tests for grit.format.policy_templates.writers.json_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.json_writer'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 HEADER_DELIMETER + 228 HEADER_DELIMETER +
229 ' // Example List\n\n' 229 ' // Example List\n\n'
230 ' //"ListPolicy": ["foo", "bar"]\n\n' 230 ' //"ListPolicy": ["foo", "bar"]\n\n'
231 '}') 231 '}')
232 self.CompareOutputs(output, expected_output) 232 self.CompareOutputs(output, expected_output)
233 233
234 def testDictionaryPolicy(self): 234 def testDictionaryPolicy(self):
235 # Tests a policy group with a single policy of type 'dict'. 235 # Tests a policy group with a single policy of type 'dict'.
236 example = { 236 example = {
237 'bool': True, 237 'bool': True,
238 'int': 10,
239 'string': 'abc',
240 'list': [1, 2, 3],
241 'dict': { 238 'dict': {
242 'a': 1, 239 'a': 1,
243 'b': 2, 240 'b': 2,
244 } 241 },
242 'int': 10,
243 'list': [1, 2, 3],
244 'string': 'abc',
245 } 245 }
246 grd = self.PrepareTest( 246 grd = self.PrepareTest(
247 '{' 247 '{'
248 ' "policy_definitions": [' 248 ' "policy_definitions": ['
249 ' {' 249 ' {'
250 ' "name": "DictionaryPolicy",' 250 ' "name": "DictionaryPolicy",'
251 ' "type": "dict",' 251 ' "type": "dict",'
252 ' "caption": "Example Dictionary Policy",' 252 ' "caption": "Example Dictionary Policy",'
253 ' "desc": "Example Dictionary Policy",' 253 ' "desc": "Example Dictionary Policy",'
254 ' "supported_on": ["chrome.linux:8-"],' 254 ' "supported_on": ["chrome.linux:8-"],'
255 ' "example_value": ' + str(example) + 255 ' "example_value": ' + str(example) +
256 ' },' 256 ' },'
257 ' ],' 257 ' ],'
258 ' "placeholders": [],' 258 ' "placeholders": [],'
259 ' "messages": {},' 259 ' "messages": {},'
260 '}') 260 '}')
261 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en') 261 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en')
262 expected_output = ( 262 expected_output = (
263 TEMPLATE_HEADER + 263 TEMPLATE_HEADER +
264 ' // Example Dictionary Policy\n' + 264 ' // Example Dictionary Policy\n' +
265 HEADER_DELIMETER + 265 HEADER_DELIMETER +
266 ' // Example Dictionary Policy\n\n' 266 ' // Example Dictionary Policy\n\n'
267 ' //"DictionaryPolicy": {\'bool\': True, \'dict\': {\'a\': 1, ' 267 ' //"DictionaryPolicy": {"bool": true, "dict": {"a": 1, '
268 '\'b\': 2}, \'int\': 10, \'list\': [1, 2, 3], \'string\': \'abc\'}\n\n' 268 '"b": 2}, "int": 10, "list": [1, 2, 3], "string": "abc"}\n\n'
269 '}') 269 '}')
270 self.CompareOutputs(output, expected_output) 270 self.CompareOutputs(output, expected_output)
271 271
272 def testNonSupportedPolicy(self): 272 def testNonSupportedPolicy(self):
273 # Tests a policy that is not supported on Linux, so it shouldn't 273 # Tests a policy that is not supported on Linux, so it shouldn't
274 # be included in the JSON file. 274 # be included in the JSON file.
275 grd = self.PrepareTest( 275 grd = self.PrepareTest(
276 '{' 276 '{'
277 ' "policy_definitions": [' 277 ' "policy_definitions": ['
278 ' {' 278 ' {'
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 ' // Policy Two\n' + 331 ' // Policy Two\n' +
332 HEADER_DELIMETER + 332 HEADER_DELIMETER +
333 ' // Policy Two\n\n' 333 ' // Policy Two\n\n'
334 ' //"Policy2": "c"\n\n' 334 ' //"Policy2": "c"\n\n'
335 '}') 335 '}')
336 self.CompareOutputs(output, expected_output) 336 self.CompareOutputs(output, expected_output)
337 337
338 338
339 if __name__ == '__main__': 339 if __name__ == '__main__':
340 unittest.main() 340 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/json_writer.py ('k') | grit/format/policy_templates/writers/plist_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698