Example #1
0
    def testGetAPIsMapNoDefaultsClientsForAPIs(self):
        config = yaml.loads(
            textwrap.dedent("""\
        orange:
          v1:
            discovery: organge_v1.json
          v2:
            discovery: organge_v2.json
    """))

        with self.assertRaises(Exception) as ctx:
            regen._MakeApiMap('fruits', config)

        msg = str(ctx.exception)
        self.assertEquals(msg,
                          'No default client versions found for [fig, lime]!')
Example #2
0
    def testGetAPIsMapNoDefaultsClientsForAPIs(self):
        config = yaml.loads(
            textwrap.dedent(
                """\
        orange:
          v1:
            discovery: organge_v1.json
          v2:
            discovery: organge_v2.json
    """
            )
        )

        with self.assertRaises(Exception) as ctx:
            regen._MakeApiMap("fruits", config)

        msg = str(ctx.exception)
        self.assertEquals(msg, "No default client versions found for [fig, lime]!")
Example #3
0
 def testGetAPIsMap(self):
     config = yaml.loads(
         textwrap.dedent(
             """\
     orange:
       v1:
         discovery: organge_v1.json
         default: True
       v2:
         discovery: organge_v2.json
     banana:
       v2beta:
         discovery: banana_v2beta.json
       v2_staging:
         version: v2
         discovery: banana_v2_staging.json
         default: True
     pear:
       v7_test:
         discovery: pear_v7_test.json
 """
         )
     )
     expected_map = {
         "orange": {
             "v1": api_def.APIDef(
                 "fruits.orange.v1.orange_v1_client.OrangeV1", "fruits.orange.v1.orange_v1_messages", True
             ),
             "v2": api_def.APIDef(
                 "fruits.orange.v2.orange_v2_client.OrangeV2", "fruits.orange.v2.orange_v2_messages"
             ),
         },
         "banana": {
             "v2beta": api_def.APIDef(
                 "fruits.banana.v2beta.banana_v2beta_client.BananaV2beta",
                 "fruits.banana.v2beta.banana_v2beta_messages",
             ),
             "v2_staging": api_def.APIDef(
                 "fruits.banana.v2_staging.banana_v2_client.BananaV2",
                 "fruits.banana.v2_staging.banana_v2_messages",
                 True,
             ),
         },
         "pear": {
             "v7_test": api_def.APIDef(
                 "fruits.pear.v7_test.pear_v7_test_client.PearV7Test",
                 "fruits.pear.v7_test.pear_v7_test_messages",
                 True,
             )
         },
     }
     actual_map = regen._MakeApiMap("fruits", config)
     self.assertEquals(expected_map, actual_map)
Example #4
0
 def testGetAPIsMap(self):
     config = yaml.loads(
         textwrap.dedent("""\
     orange:
       v1:
         discovery: organge_v1.json
         default: True
       v2:
         discovery: organge_v2.json
     banana:
       v2beta:
         discovery: banana_v2beta.json
       v2_staging:
         version: v2
         discovery: banana_v2_staging.json
         default: True
     pear:
       v7_test:
         discovery: pear_v7_test.json
 """))
     expected_map = {
         'orange': {
             'v1':
             api_def.APIDef('fruits.orange.v1.orange_v1_client.OrangeV1',
                            'fruits.orange.v1.orange_v1_messages', True),
             'v2':
             api_def.APIDef('fruits.orange.v2.orange_v2_client.OrangeV2',
                            'fruits.orange.v2.orange_v2_messages')
         },
         'banana': {
             'v2beta':
             api_def.APIDef(
                 'fruits.banana.v2beta.banana_v2beta_client.BananaV2beta',
                 'fruits.banana.v2beta.banana_v2beta_messages'),
             'v2_staging':
             api_def.APIDef(
                 'fruits.banana.v2_staging.banana_v2_client.BananaV2',
                 'fruits.banana.v2_staging.banana_v2_messages', True)
         },
         'pear': {
             'v7_test':
             api_def.APIDef(
                 'fruits.pear.v7_test.pear_v7_test_client.PearV7Test',
                 'fruits.pear.v7_test.pear_v7_test_messages', True)
         }
     }
     actual_map = regen._MakeApiMap('fruits', config)
     self.assertEquals(expected_map, actual_map)