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

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

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove whitespace 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 unittest 7 import unittest
8 8
9 class ModelTest(unittest.TestCase): 9 class ModelTest(unittest.TestCase):
10 def setUp(self): 10 def setUp(self):
(...skipping 19 matching lines...) Expand all
30 self.permissions_json[0]['namespace'] = 'something' 30 self.permissions_json[0]['namespace'] = 'something'
31 self.permissions_json[0]['nocompile'] = True 31 self.permissions_json[0]['nocompile'] = True
32 self.model.AddNamespace(self.permissions_json[0], 32 self.model.AddNamespace(self.permissions_json[0],
33 'path/to/something.json') 33 'path/to/something.json')
34 self.assertEquals(3, len(self.model.namespaces)) 34 self.assertEquals(3, len(self.model.namespaces))
35 35
36 def testHasFunctions(self): 36 def testHasFunctions(self):
37 self.assertEquals(["contains", "getAll", "remove", "request"], 37 self.assertEquals(["contains", "getAll", "remove", "request"],
38 sorted(self.permissions.functions.keys())) 38 sorted(self.permissions.functions.keys()))
39 39
40 def testFunctionNoCallback(self):
41 del (self.permissions_json[0]['functions'][0]['parameters'][0])
42 self.assertRaises(AssertionError, self.model.AddNamespace,
43 self.permissions_json[0], 'path/to/something.json')
44
45 def testFunctionNoCompile(self): 40 def testFunctionNoCompile(self):
46 # tabs.json has 2 functions marked as nocompile (connect, sendRequest) 41 # tabs.json has 2 functions marked as nocompile (connect, sendRequest)
47 self.assertEquals(["captureVisibleTab", "create", "detectLanguage", 42 self.assertEquals(["captureVisibleTab", "create", "detectLanguage",
48 "executeScript", "get", "getAllInWindow", "getCurrent", 43 "executeScript", "get", "getAllInWindow", "getCurrent",
49 "getSelected", "highlight", "insertCSS", "move", "query", "reload", 44 "getSelected", "highlight", "insertCSS", "move", "query", "reload",
50 "remove", "update"], 45 "remove", "update"],
51 sorted(self.tabs.functions.keys()) 46 sorted(self.tabs.functions.keys())
52 ) 47 )
53 48
54 def testHasTypes(self): 49 def testHasTypes(self):
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 param.choices[model.PropertyType.INTEGER].GetUnixName) 96 param.choices[model.PropertyType.INTEGER].GetUnixName)
102 param.choices[model.PropertyType.INTEGER].unix_name = 'asdf' 97 param.choices[model.PropertyType.INTEGER].unix_name = 'asdf'
103 param.choices[model.PropertyType.INTEGER].unix_name = 'tab_ids_integer' 98 param.choices[model.PropertyType.INTEGER].unix_name = 'tab_ids_integer'
104 self.assertEquals('tab_ids_integer', 99 self.assertEquals('tab_ids_integer',
105 param.choices[model.PropertyType.INTEGER].unix_name) 100 param.choices[model.PropertyType.INTEGER].unix_name)
106 self.assertRaises(AttributeError, 101 self.assertRaises(AttributeError,
107 param.choices[model.PropertyType.INTEGER].SetUnixName, 'breakage') 102 param.choices[model.PropertyType.INTEGER].SetUnixName, 'breakage')
108 103
109 if __name__ == '__main__': 104 if __name__ == '__main__':
110 unittest.main() 105 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698