def testGlobalAttributes(self): d = yaml_command_schema.CommandData('describe', self.MakeCommandData()) d.hidden = True d.release_tracks = [ calliope_base.ReleaseTrack.GA, calliope_base.ReleaseTrack.BETA ] cb = yaml_command_translator.CommandBuilder(d, ['abc', 'xyz', 'describe']) class TempCommand(calliope_base.Command): pass cb._ConfigureGlobalAttributes(TempCommand) self.assertEqual(TempCommand.IsHidden(), True) self.assertEqual( TempCommand.ValidReleaseTracks(), {calliope_base.ReleaseTrack.GA, calliope_base.ReleaseTrack.BETA}) self.assertEqual( TempCommand.detailed_help, { 'brief': 'brief help', 'API REFERENCE': 'This command uses the *foo/v1* API. The full ' 'documentation for this API can be found at: ' 'https://cloud.google.com/docs' })
def testUnknownCommandType(self): cb = yaml_command_translator.CommandBuilder( yaml_command_schema.CommandData('describe', self.MakeCommandData()), ['abc', 'xyz', 'describe']) cb.spec.command_type = 'bogus' with self.assertRaisesRegex( ValueError, r'Command \[abc xyz describe] unknown command type \[bogus]\.' ): cb.Generate()
def ValidateBuild(self): try: # Implicitly ensures that all python hooks are valid. spec = yaml_command_schema.CommandData(self.path[-1], self.command_data) # The ensures that the api collection, version, and method are all valid. c = yaml_command_translator.CommandBuilder(spec, ['abc', 'xyz', 'list']) c.Generate() return c # pylint: disable=broad-except, We are just logging it here. except Exception as e: self.E('GLOBAL', 'Command loading failed: ' + str(e))
def Translate(self, path, command_data): return yaml_command_translator.CommandBuilder( self.spec, ['abc', 'xyz', self.name]).Generate()