def config(): return Config( project="PROJ", completed={"Done"}, in_progress={"In progress", "Review"}, analyse_issue_types=None, defect_types={"Bug"}, )
def config(): return Config( project="PROJ", completed={"Done"}, in_progress={"In Progress"}, analyse_issue_types={"Story", "Bug", "Spike"}, defect_types={"Bug"}, )
def config(): return Config( project="PROJ", completed={"Done"}, in_progress={"In progress"}, analyse_issue_types=None, defect_types={"Bug"}, exclude_issues=set(), )
def create_issue_with_config( config: Config, key: str, changelog: List[Tuple[_STATUS_TO, date]], related: List[Tuple[_ISSUE_KEY, _ISSUE_TYPE]], ) -> Issue: try: completed = min(t for c, t in changelog if config.is_completed_status(c)) except ValueError: raise IssueNotComplete(key) return Issue( key=key, completed=completed, defects=[ Defect(key=k) for k, t in related if config.is_defect_type(t) ], )
def get_config(**overrides): config_args = { "project": "PROJ-123", "in_progress": {"In Progress"}, "completed": {"Done"}, "analyse_issue_types": None, "jira_url": "jira.atlassian.net", } config_args.update(overrides) return Config(**config_args)
def get_config(**overrides): config_args = { "project": "PROJ-123", "in_progress": {"In Progress"}, "completed": {"Done"}, "analyse_issue_types": None, "defect_types": {"Bug"}, "exclude_issues": set(), } config_args.update(overrides) return Config(**config_args)
def create_issue_with_config( config: Config, key: str, created: datetime, status: str, changelog: Iterable[Tuple[str, datetime]], ) -> Issue: completed = started = None for change, updated in sorted(changelog, key=it.last): if config.is_completed_status(change) and completed is None: completed = updated if config.is_in_progress_status(change) and started is None: started = updated return Issue( key=key, created=created, completed=completed, started=started, status=status, )
def create_issue_with_config( key: str, completed: date, status: str, config: Config ) -> Issue: """Create an issue from the given key and completed date. The config is used to determine if the issue is complete. If the issue is not complete, this raises an exception. :param key: The issue key. :param completed: The date the issue was completed. :param config: The config. :return: The new issue. :raises IssueNotComplete: If the given status is not a completed status. """ if not config.is_completed_status(status) or completed is None: raise IssueNotComplete(key, status) return Issue(key=key, completed=completed)
def convert_jira_to_throughput(jira_ticket: JiraTicket, config: Config) -> Issue: """Take a given Jira Ticket and convert it into a Throughput ticket. :param jira_ticket: The Jira Ticket to convert. :param config: The Configuration. :return: A Throughput ticket. :raises IssueNotComplete: If the given ticket isn't marked as complete. """ for change in jira_ticket.changelog: if config.is_completed_status(change.status_to): completed = change.created break return create_issue_with_config( key=jira_ticket.key, completed=completed.date(), status=jira_ticket.status, config=config, )
@pytest.mark.parametrize( "test_input,expected_result", [("Done", False), ("In progress", True)] ) def test_config_is_in_progress_status(test_input, expected_result, config): assert config.is_in_progress_status(test_input) == expected_result @pytest.mark.parametrize( "test_config,test_input,expected_result", [ ( Config( project="PROJ", completed={"Done"}, in_progress={"In progress", "Review"}, analyse_issue_types=None, defect_types={"Bug"}, ), "Bug", True, ), ( Config( project="PROJ", completed={"Done"}, in_progress={"In progress", "Review"}, analyse_issue_types={"Story", "Task"}, defect_types={"Bug"}, ), "Story",