def testAddToApisMap(self): with self.assertRaisesRegex( apis_util.UnknownAPIError, r'API named \[hello\] does not exist in the APIs map'): apis_internal._GetApiDef('hello', 'v1') expected_api_def = apis.ConstructApiDef('hello', 'v1', True) apis.AddToApisMap('hello', 'v1', True) self.assertEqual('v1', apis_internal._GetDefaultVersion('hello')) self.assertEqual(expected_api_def, apis_internal._GetApiDef('hello', 'v1'))
def testGetApiDefWithOverride(self): expected_api_def = apis.ConstructApiDef('compute', 'alpha', False) properties.VALUES.api_client_overrides.compute.Set('alpha') actual_api_def = apis_internal._GetApiDef('compute', 'v1') self.assertEqual(expected_api_def, actual_api_def)
def testConstructAPIDef(self): expected_api_def = apis_map.APIDef( 'googlecloudsdk.third_party.apis.dns.v1', 'dns_v1_client.DnsV1', 'dns_v1_messages', True) actual_api_def = apis.ConstructApiDef('dns', 'v1', True) self.assertEqual(expected_api_def, actual_api_def)
def testGetDefaultApiDef(self): expected_api_def = apis.ConstructApiDef('dns', 'v1', True) actual_api_def = apis_internal._GetApiDef('dns', 'v1') self.assertEqual(expected_api_def, actual_api_def)