OLD | NEW |
| 1 #!/usr/bin/env python |
| 2 |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 3 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 5 # found in the LICENSE file. |
4 | 6 |
5 import argparse | |
6 import client_api_generator | 7 import client_api_generator |
7 import shutil | 8 import shutil |
8 import sys | 9 import sys |
9 import tempfile | 10 import tempfile |
10 import unittest | 11 import unittest |
11 | 12 |
12 | 13 |
13 class ClientApiGeneratorTest(unittest.TestCase): | 14 class ClientApiGeneratorTest(unittest.TestCase): |
14 | 15 |
15 def test_ArgumentParsing(self): | 16 def test_ArgumentParsing(self): |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 {'name': 'r6', 'type': 'object', '$ref': 'domain.TestType'}, | 447 {'name': 'r6', 'type': 'object', '$ref': 'domain.TestType'}, |
447 ], | 448 ], |
448 }, | 449 }, |
449 ] | 450 ] |
450 }, | 451 }, |
451 ] | 452 ] |
452 } | 453 } |
453 try: | 454 try: |
454 dirname = tempfile.mkdtemp() | 455 dirname = tempfile.mkdtemp() |
455 jinja_env = client_api_generator.InitializeJinjaEnv(dirname) | 456 jinja_env = client_api_generator.InitializeJinjaEnv(dirname) |
| 457 client_api_generator.CreateTypeDefinitions(json_api) |
456 client_api_generator.Generate(jinja_env, dirname, json_api, 'types', | 458 client_api_generator.Generate(jinja_env, dirname, json_api, 'types', |
457 ['cc']) | 459 ['cc']) |
458 client_api_generator.Generate(jinja_env, dirname, json_api, 'types', | 460 client_api_generator.Generate(jinja_env, dirname, json_api, 'types', |
459 ['h']) | 461 ['h']) |
460 # This is just a smoke test; we don't actually verify the generated output | 462 # This is just a smoke test; we don't actually verify the generated output |
461 # here. | 463 # here. |
462 finally: | 464 finally: |
463 shutil.rmtree(dirname) | 465 shutil.rmtree(dirname) |
464 | 466 |
465 def test_GenerateDomains(self): | 467 def test_GenerateDomains(self): |
(...skipping 24 matching lines...) Expand all Loading... |
490 jinja_env = client_api_generator.InitializeJinjaEnv(dirname) | 492 jinja_env = client_api_generator.InitializeJinjaEnv(dirname) |
491 client_api_generator.GenerateDomains(jinja_env, dirname, json_api, | 493 client_api_generator.GenerateDomains(jinja_env, dirname, json_api, |
492 'domain', ['cc', 'h']) | 494 'domain', ['cc', 'h']) |
493 # This is just a smoke test; we don't actually verify the generated output | 495 # This is just a smoke test; we don't actually verify the generated output |
494 # here. | 496 # here. |
495 finally: | 497 finally: |
496 shutil.rmtree(dirname) | 498 shutil.rmtree(dirname) |
497 | 499 |
498 | 500 |
499 if __name__ == '__main__': | 501 if __name__ == '__main__': |
500 cmdline_parser = argparse.ArgumentParser() | 502 unittest.main(verbosity=2, exit=False, argv=sys.argv) |
501 cmdline_parser.add_argument('--stamp') | |
502 args = cmdline_parser.parse_args() | |
503 unittest.main(verbosity=2, exit=False, argv=sys.argv[:1]) | |
504 if args.stamp: | |
505 with open(args.stamp, 'a') as f: | |
506 pass | |
OLD | NEW |