def test_GenerateDomains(self):
     json_api = {
         'domains': [
             {
                 'domain': 'domain0',
                 'types': [
                     {
                         'id': 'TestType',
                         'type': 'object',
                     },
                 ]
             },
             {
                 'domain': 'domain1',
                 'types': [
                     {
                         'id': 'TestType',
                         'type': 'object',
                     },
                 ]
             },
         ]
     }
     try:
         dirname = tempfile.mkdtemp()
         jinja_env = client_api_generator.InitializeJinjaEnv(dirname)
         client_api_generator.GenerateDomains(jinja_env, dirname, json_api,
                                              'domain', ['cc', 'h'])
         # This is just a smoke test; we don't actually verify the generated output
         # here.
     finally:
         shutil.rmtree(dirname)
Ejemplo n.º 2
0
 def test_Generate(self):
     json_api = {
         'domains': [
             {
                 'domain':
                 'domain',
                 'types': [
                     {
                         'id':
                         'TestType',
                         'type':
                         'object',
                         'properties': [
                             {
                                 'name': 'p1',
                                 'type': 'number'
                             },
                             {
                                 'name': 'p2',
                                 'type': 'integer'
                             },
                             {
                                 'name': 'p3',
                                 'type': 'boolean'
                             },
                             {
                                 'name': 'p4',
                                 'type': 'string'
                             },
                             {
                                 'name': 'p5',
                                 'type': 'any'
                             },
                             {
                                 'name': 'p6',
                                 'type': 'object',
                                 '$ref': 'domain.TestType'
                             },
                         ],
                         'returns': [
                             {
                                 'name': 'r1',
                                 'type': 'number'
                             },
                             {
                                 'name': 'r2',
                                 'type': 'integer'
                             },
                             {
                                 'name': 'r3',
                                 'type': 'boolean'
                             },
                             {
                                 'name': 'r4',
                                 'type': 'string'
                             },
                             {
                                 'name': 'r5',
                                 'type': 'any'
                             },
                             {
                                 'name': 'r6',
                                 'type': 'object',
                                 '$ref': 'domain.TestType'
                             },
                         ],
                     },
                 ]
             },
         ]
     }
     try:
         dirname = tempfile.mkdtemp()
         jinja_env = client_api_generator.InitializeJinjaEnv(dirname)
         client_api_generator.CreateTypeDefinitions(json_api)
         client_api_generator.GenerateDomains(jinja_env, dirname, json_api)
         # This is just a smoke test; we don't actually verify the generated output
         # here.
     finally:
         shutil.rmtree(dirname)