diff options
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() - |