| OLD | NEW |
| (Empty) | |
| 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 |
| 7 import os |
| 8 import unittest |
| 9 |
| 10 from handlebar_dict_generator import HandlebarDictGenerator |
| 11 import third_party.json_schema_compiler.json_comment_eater as comment_eater |
| 12 import third_party.json_schema_compiler.model as model |
| 13 |
| 14 class DictGeneratorTest(unittest.TestCase): |
| 15 def setUp(self): |
| 16 self._base_path = os.path.join('test_data', 'test_json') |
| 17 |
| 18 def _ReadLocalFile(self, filename): |
| 19 with open(os.path.join(self._base_path, filename), 'r') as f: |
| 20 return f.read() |
| 21 |
| 22 def _GenerateTest(self, filename): |
| 23 expected_json = json.loads(self._ReadLocalFile('expected_' + filename)) |
| 24 gen = HandlebarDictGenerator( |
| 25 json.loads(comment_eater.Nom(self._ReadLocalFile(filename)))[0]) |
| 26 self.assertEquals(expected_json, gen.Generate()) |
| 27 |
| 28 def testGenerate(self): |
| 29 self._GenerateTest('test_file.json') |
| 30 |
| 31 if __name__ == '__main__': |
| 32 unittest.main() |
| OLD | NEW |