diff options
author | gfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 17:46:14 +0000 |
---|---|---|
committer | gfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 17:46:14 +0000 |
commit | 0bb5ad3af6cc6d483a570b2eafce59ee9b86d244 (patch) | |
tree | 5491b261883db8e3aec512e80f32476275374367 /tools/grit | |
parent | 8d0418a4708121025199bb48dd5a8c33652d5abb (diff) | |
download | chromium_src-0bb5ad3af6cc6d483a570b2eafce59ee9b86d244.zip chromium_src-0bb5ad3af6cc6d483a570b2eafce59ee9b86d244.tar.gz chromium_src-0bb5ad3af6cc6d483a570b2eafce59ee9b86d244.tar.bz2 |
Fix generating descriptions of policy template strings
BUG=none
TEST=python:PolicyJsonUnittest.*
Review URL: http://codereview.chromium.org/6312006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/grit')
-rw-r--r-- | tools/grit/grit/gather/policy_json.py | 6 | ||||
-rw-r--r-- | tools/grit/grit/gather/policy_json_unittest.py | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/tools/grit/grit/gather/policy_json.py b/tools/grit/grit/gather/policy_json.py index c4545088..308fe0d 100644 --- a/tools/grit/grit/gather/policy_json.py +++ b/tools/grit/grit/gather/policy_json.py @@ -147,11 +147,13 @@ class PolicyJson(skeleton_gatherer.SkeletonGatherer): 'caption': 'Caption', 'label': 'Label', } - if type == 'policy': + if item_type == 'policy': return '%s of the policy named %s' % (key_map[key], item['name']) - elif type == 'enum_item': + elif item_type == 'enum_item': return ('%s of the option named %s in policy %s' % (key_map[key], item['name'], parent_item['name'])) + else: + raise Exception('Unexpected type %s' % item_type) def _AddPolicyKey(self, item, item_type, parent_item, key, depth): '''Given a policy/enumeration item and a key, adds that key and its value diff --git a/tools/grit/grit/gather/policy_json_unittest.py b/tools/grit/grit/gather/policy_json_unittest.py index f443e43..9f141d6 100644 --- a/tools/grit/grit/gather/policy_json_unittest.py +++ b/tools/grit/grit/gather/policy_json_unittest.py @@ -65,8 +65,10 @@ class PolicyJsonUnittest(unittest.TestCase): "{" " 'policy_definitions': [" " {" + " 'name': 'Policy1'," " 'items': [" " {" + " 'name': 'Item1'," " 'caption': 'nothing special'," " }" " ]" @@ -88,6 +90,7 @@ class PolicyJsonUnittest(unittest.TestCase): " {" " 'policies': [" " {" + " 'name': 'Policy1'," " 'caption': 'nothing special'," " }" " ]" @@ -150,6 +153,7 @@ with a newline?''', original = """{ 'policy_definitions': [ { + 'name': 'Policy1', 'caption': '''Please install <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.''', }, @@ -170,7 +174,22 @@ with a newline?''', self.failUnless(ph.GetPresentation() == 'PRODUCT_NAME') self.failUnless(ph.GetExample() == 'Google Chrome') + def testGetDescription(self): + gatherer = policy_json.PolicyJson({}) + self.assertEquals( + gatherer._GetDescription({'name': 'Policy1'}, 'policy', None, 'desc'), + 'Description of the policy named Policy1') + self.assertEquals( + gatherer._GetDescription({'name': 'Plcy2'}, 'policy', None, 'caption'), + 'Caption of the policy named Plcy2') + self.assertEquals( + gatherer._GetDescription({'name': 'Plcy3'}, 'policy', None, 'label'), + 'Label of the policy named Plcy3') + self.assertEquals( + gatherer._GetDescription({'name': 'Item'}, 'enum_item', + {'name': 'Policy'}, 'caption'), + 'Caption of the option named Item in policy Policy') + if __name__ == '__main__': unittest.main() - |