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

Side by Side Diff: tools/json_schema_compiler/model_test.py

Issue 9447090: Allow comments in extension config files. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added minify to some files in tools/json_schema_compiler Created 8 years, 9 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import model 6 import model
7 import os
8 import sys
7 import unittest 9 import unittest
8 10
11 # We need to get json_minify from the third_party directory.
12 # This is similar to what is done in chrome/common/extensions/docs/build.py
13 third_party_path = os.path.dirname(os.path.realpath(__file__)) + \
14 '/../../third_party/'
15 if third_party_path not in sys.path:
16 sys.path.insert(0, third_party_path)
17 import json_minify as minify
not at google - send to devlin 2012/03/02 02:15:08 yeah, definitely nicer to have this all packaged a
18
9 class ModelTest(unittest.TestCase): 19 class ModelTest(unittest.TestCase):
10 def setUp(self): 20 def setUp(self):
11 self.model = model.Model() 21 self.model = model.Model()
12 self.permissions_json = json.loads(open('test/permissions.json').read()) 22 self.permissions_json = json.loads(minify.json_minify(
23 open('test/permissions.json').read()))
13 self.model.AddNamespace(self.permissions_json[0], 24 self.model.AddNamespace(self.permissions_json[0],
14 'path/to/permissions.json') 25 'path/to/permissions.json')
15 self.permissions = self.model.namespaces.get('permissions') 26 self.permissions = self.model.namespaces.get('permissions')
16 self.windows_json = json.loads(open('test/windows.json').read()) 27 self.windows_json = json.loads(minify.json_minify(
28 open('test/windows.json').read()))
17 self.model.AddNamespace(self.windows_json[0], 29 self.model.AddNamespace(self.windows_json[0],
18 'path/to/window.json') 30 'path/to/window.json')
19 self.windows = self.model.namespaces.get('windows') 31 self.windows = self.model.namespaces.get('windows')
20 self.tabs_json = json.loads(open('test/tabs.json').read()) 32 self.tabs_json = json.loads(minify.json_minify(
33 open('test/tabs.json').read()))
21 self.model.AddNamespace(self.tabs_json[0], 34 self.model.AddNamespace(self.tabs_json[0],
22 'path/to/tabs.json') 35 'path/to/tabs.json')
23 self.tabs = self.model.namespaces.get('tabs') 36 self.tabs = self.model.namespaces.get('tabs')
24 37
25 def testNamespaces(self): 38 def testNamespaces(self):
26 self.assertEquals(3, len(self.model.namespaces)) 39 self.assertEquals(3, len(self.model.namespaces))
27 self.assertTrue(self.permissions) 40 self.assertTrue(self.permissions)
28 41
29 def testNamespaceNoCompile(self): 42 def testNamespaceNoCompile(self):
30 self.permissions_json[0]['namespace'] = 'something' 43 self.permissions_json[0]['namespace'] = 'something'
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 param.choices[model.PropertyType.INTEGER].GetUnixName) 114 param.choices[model.PropertyType.INTEGER].GetUnixName)
102 param.choices[model.PropertyType.INTEGER].unix_name = 'asdf' 115 param.choices[model.PropertyType.INTEGER].unix_name = 'asdf'
103 param.choices[model.PropertyType.INTEGER].unix_name = 'tab_ids_integer' 116 param.choices[model.PropertyType.INTEGER].unix_name = 'tab_ids_integer'
104 self.assertEquals('tab_ids_integer', 117 self.assertEquals('tab_ids_integer',
105 param.choices[model.PropertyType.INTEGER].unix_name) 118 param.choices[model.PropertyType.INTEGER].unix_name)
106 self.assertRaises(AttributeError, 119 self.assertRaises(AttributeError,
107 param.choices[model.PropertyType.INTEGER].SetUnixName, 'breakage') 120 param.choices[model.PropertyType.INTEGER].SetUnixName, 'breakage')
108 121
109 if __name__ == '__main__': 122 if __name__ == '__main__':
110 unittest.main() 123 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698