def testRuntimeHandlerArgNameToConceptInfo(self): resource_info = info_holders.ResourceInfo( '--book', self.resource_spec, 'group help', { 'book': '--book', 'shelf': '--shelf', 'project': '--book-project' }, {}) runtime_handler = handlers.RuntimeHandler() runtime_handler.AddConcept('book', resource_info) self.assertEqual(resource_info, runtime_handler.ArgNameToConceptInfo('book')) self.assertEqual(resource_info, runtime_handler.ArgNameToConceptInfo('shelf')) self.assertEqual(resource_info, runtime_handler.ArgNameToConceptInfo('book_project'))
def _GenerateInfo(self): """Gets the ResourceInfo object for the ConceptParser. Returns: info_holders.ResourceInfo, the ResourceInfo object. """ fallthroughs_map = {} for attribute in self.concept_spec.attributes: fallthroughs_map[attribute.name] = attribute.fallthroughs return info_holders.ResourceInfo(self.name, self.concept_spec, self.group_help, self.attribute_to_args_map, fallthroughs_map, required=self.required, plural=self.plural, group=self.group)
def SetUpResourceInfo(self, name): """Sets up a test ConceptInfo for a ResourcePresentationSpec. Uses an example resource. Args: name: str, the name of the anchor argument for the concept spec. Returns: (handlers.ConceptInfo) the concept handler. """ resource_info = info_holders.ResourceInfo( name, self.resource_spec, 'a resource', { 'book': name, 'shelf': '--shelf', 'project': '--book-project' }, {}) return resource_info
def _GenerateInfo(self, fallthroughs_map): """Gets the ResourceInfo object for the ConceptParser. Args: fallthroughs_map: {str: [googlecloudsdk.calliope.concepts.deps. _FallthroughBase]}, dict keyed by attribute name to lists of fallthroughs. Returns: info_holders.ResourceInfo, the ResourceInfo object. """ return info_holders.ResourceInfo(self.name, self.concept_spec, self.group_help, self.attribute_to_args_map, fallthroughs_map, required=self.required, plural=self.plural, group=self.group)