1 #!/usr/bin/env python 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 4 # found in the LICENSE file. 5 6 import json_schema 7 import json_schema_test 8 import unittest 9 10 class JsonSchemaUnittest(unittest.TestCase): 11 def testNocompile(self): 12 compiled = [ 13 { 14 "namespace": "compile", 15 "description": "The compile API.", 16 "functions": [], 17 "types": {} 18 }, 19 20 { 21 "namespace": "functions", 22 "description": "The functions API.", 23 "functions": [ 24 { 25 "id": "two" 26 }, 27 { 28 "id": "four" 29 } 30 ], 31 32 "types": { 33 "one": { "key": "value" } 34 } 35 }, 36 37 { 38 "namespace": "types", 39 "description": "The types API.", 40 "functions": [ 41 { "id": "one" } 42 ], 43 "types": { 44 "two": { 45 "key": "value" 46 }, 47 "four": { 48 "key": "value" 49 } 50 } 51 }, 52 53 { 54 "namespace": "nested", 55 "description": "The nested API.", 56 "properties": { 57 "sync": { 58 "functions": [ 59 { 60 "id": "two" 61 }, 62 { 63 "id": "four" 64 } 65 ], 66 "types": { 67 "two": { 68 "key": "value" 69 }, 70 "four": { 71 "key": "value" 72 } 73 } 74 } 75 } 76 } 77 ] 78 79 schema = json_schema.CachedLoad('test/json_schema_test.json') 80 self.assertEquals(compiled, json_schema.DeleteNodes(schema, 'nocompile')) 81 82 if __name__ == '__main__': 83 unittest.main() 84