| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import json_schema | 6 import json_schema |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 class JsonSchemaUnittest(unittest.TestCase): | 9 class JsonSchemaUnittest(unittest.TestCase): |
| 10 def testNocompile(self): | 10 def testNocompile(self): |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 ] | 76 ] |
| 77 | 77 |
| 78 schema = json_schema.CachedLoad('test/json_schema_test.json') | 78 schema = json_schema.CachedLoad('test/json_schema_test.json') |
| 79 self.assertEquals(compiled, json_schema.DeleteNodes(schema, 'nocompile')) | 79 self.assertEquals(compiled, json_schema.DeleteNodes(schema, 'nocompile')) |
| 80 | 80 |
| 81 def should_delete(value): |
| 82 return isinstance(value, dict) and not value.get('valid', True) |
| 83 expected = [ |
| 84 {'one': {'test': 'test'}}, |
| 85 {'valid': True}, |
| 86 {} |
| 87 ] |
| 88 given = [ |
| 89 {'one': {'test': 'test'}, 'two': {'valid': False}}, |
| 90 {'valid': True}, |
| 91 {}, |
| 92 {'valid': False} |
| 93 ] |
| 94 self.assertEquals( |
| 95 expected, json_schema.DeleteNodes(given, matcher=should_delete)) |
| 96 |
| 81 | 97 |
| 82 if __name__ == '__main__': | 98 if __name__ == '__main__': |
| 83 unittest.main() | 99 unittest.main() |
| OLD | NEW |