| OLD | NEW |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'json', 'en') | 79 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'json', 'en') |
| 80 expected_output = ( | 80 expected_output = ( |
| 81 TEMPLATE_HEADER + | 81 TEMPLATE_HEADER + |
| 82 ' // Example Main Policy\n' + | 82 ' // Example Main Policy\n' + |
| 83 HEADER_DELIMETER + | 83 HEADER_DELIMETER + |
| 84 ' // Example Main Policy\n\n' | 84 ' // Example Main Policy\n\n' |
| 85 ' //"MainPolicy": true\n\n' | 85 ' //"MainPolicy": true\n\n' |
| 86 '}') | 86 '}') |
| 87 self.CompareOutputs(output, expected_output) | 87 self.CompareOutputs(output, expected_output) |
| 88 | 88 |
| 89 def testRecommendedOnlyPolicy(self): |
| 90 # Tests a policy group with a single policy of type 'main'. |
| 91 grd = self.PrepareTest( |
| 92 '{' |
| 93 ' "policy_definitions": [' |
| 94 ' {' |
| 95 ' "name": "MainPolicy",' |
| 96 ' "type": "main",' |
| 97 ' "caption": "Example Main Policy",' |
| 98 ' "desc": "Example Main Policy",' |
| 99 ' "features": {' |
| 100 ' "can_be_recommended": True,' |
| 101 ' "can_be_mandatory": False' |
| 102 ' },' |
| 103 ' "supported_on": ["chrome.linux:8-"],' |
| 104 ' "example_value": True' |
| 105 ' },' |
| 106 ' ],' |
| 107 ' "placeholders": [],' |
| 108 ' "messages": {},' |
| 109 '}') |
| 110 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'json', 'en') |
| 111 expected_output = ( |
| 112 TEMPLATE_HEADER + |
| 113 ' // Note: this policy is supported only in recommended mode.\n' + |
| 114 ' // The JSON file should be placed in' + |
| 115 ' /etc/opt/chrome/policies/recommended.\n' + |
| 116 ' // Example Main Policy\n' + |
| 117 HEADER_DELIMETER + |
| 118 ' // Example Main Policy\n\n' |
| 119 ' //"MainPolicy": true\n\n' |
| 120 '}') |
| 121 self.CompareOutputs(output, expected_output) |
| 122 |
| 89 def testStringPolicy(self): | 123 def testStringPolicy(self): |
| 90 # Tests a policy group with a single policy of type 'string'. | 124 # Tests a policy group with a single policy of type 'string'. |
| 91 grd = self.PrepareTest( | 125 grd = self.PrepareTest( |
| 92 '{' | 126 '{' |
| 93 ' "policy_definitions": [' | 127 ' "policy_definitions": [' |
| 94 ' {' | 128 ' {' |
| 95 ' "name": "StringPolicy",' | 129 ' "name": "StringPolicy",' |
| 96 ' "type": "string",' | 130 ' "type": "string",' |
| 97 ' "caption": "Example String Policy",' | 131 ' "caption": "Example String Policy",' |
| 98 ' "desc": "Example String Policy",' | 132 ' "desc": "Example String Policy",' |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 ' // Policy Two\n' + | 398 ' // Policy Two\n' + |
| 365 HEADER_DELIMETER + | 399 HEADER_DELIMETER + |
| 366 ' // Policy Two\n\n' | 400 ' // Policy Two\n\n' |
| 367 ' //"Policy2": "c"\n\n' | 401 ' //"Policy2": "c"\n\n' |
| 368 '}') | 402 '}') |
| 369 self.CompareOutputs(output, expected_output) | 403 self.CompareOutputs(output, expected_output) |
| 370 | 404 |
| 371 | 405 |
| 372 if __name__ == '__main__': | 406 if __name__ == '__main__': |
| 373 unittest.main() | 407 unittest.main() |
| OLD | NEW |