def run_properties(self): """Lists the system's properties (Milestone, Component, etc.). usage: cm properties """ properties = self.get_properties() def extract_options(prop): options = [] options += prop["options"] if "optgroups" in prop: for optgroup in prop["optgroups"]: options += optgroup["options"] return options output = [] for title, prop in (("Milestones", "milestone"), ("Components", "component"), ("Status", "status"), ("Priorities", "priority")): if prop in properties: output.extend([ ui.title(title), ", ".join(extract_options(properties[prop])), ""]) return output
def print_function_help(self, attrname): """Print the docstring for one function. :param attrname: Name of the function, with the run_ prefix. """ func_name = attrname[4:] print(ui.title(func_name)) print(getattr(self, attrname).__doc__)
def run_properties(self): """Lists the system's properties (Milestone, Component, etc.). usage: cm properties """ properties = self._get_properties() print(ui.title("Milestones")) print(", ".join(properties["milestone"]["options"]) + "\n") print(ui.title("Components")) print(", ".join(properties["component"]["options"]) + "\n") print(ui.title("Status")) print(", ".join(properties["status"]["options"]) + "\n") print(ui.title("Priority")) print(", ".join(properties["priority"]["options"]) + "\n")
def run_view(self, ticket_id): """Display a ticket summary. usage: cm view ticket_id """ ticket_id = text.validate_id(ticket_id) query_string = "/ticket/{}?format=tab".format(ticket_id) t = next(self.get_tickets(query_string)) title = t.format_title() print(ui.title(title)) print("") print(t.description)
def run_properties(self): """Lists the system's properties (Milestone, Component, etc.). usage: cm properties """ self.login() options = self.get_property_options() output = [] for title, prop in (("Milestones", "milestone"), ("Components", "component"), ("Status", "status"), ("Priorities", "priority")): if prop in options: output.extend([ui.title(title), ", ".join(options[prop]), ""]) return output
def run_properties(self): """Lists the system's properties (Milestone, Component, etc.). usage: cm properties """ properties = self.get_properties() output = [] for title, prop in (("Milestones", "milestone"), ("Components", "component"), ("Status", "status"), ("Priorities", "priority")): if prop in properties: output.extend([ ui.title(title), ", ".join(properties[prop]["options"]), ""]) return output
def run_view(self, ticket_id): """Display a ticket summary. usage: cm view ticket_id """ ticket_id = text.validate_id(ticket_id) query_string = "/ticket/{}?format=tab".format(ticket_id) self.login() t = next(self.get_tickets(query_string)) title = t.format_title() return [ ui.title(title), "", t.description, ]
def test_title_with_space(self): self.assertEquals(ui.title("a bcd"), "a bcd\n-----")
def test_title_one(self): self.assertEquals(ui.title("a"), "a\n-")
def test_title_empty(self): self.assertEquals(ui.title(""), "")