Beispiel #1
0
def parse_issue_card(card_edge: dict, config: Configuration):
    return {
        "id": card_edge.get('node', {}).get('id'),
        "cursor": card_edge['cursor'],
        "issue": Issue(**parse_issue(card_edge.get('node', {}).get('content')),
                       priority_list=config.priority_list)
    }
Beispiel #2
0
    def construct_issue_object(self, github_issues):
        issues = {}
        for edge in github_issues:
            node_data = edge['node']
            issue_labels = get_labels(node_data['labels']['edges'])
            if is_matching_issue(issue_labels, self.config.must_have_labels, self.config.cant_have_labels,
                                 self.config.filter_labels):
                issue = Issue(**parse_issue(node_data), priority_list=self.config.priority_list)
                issues[issue.id] = issue

        return issues
 def get_issue_object(self):
     issue_number = self.get_issue_number(self.event)
     issue_response = self.client.get_issue(
         self.project_owner, self.repository_name, issue_number)  # need to address the remove here
     issue = Issue(**parse_issue(issue_response['repository']['issue']))
     return issue
def test_parse_issue():
    issue_id = "=asdf=sdf="
    title = "issue name"
    labels = ["HighEffort", "Low", "bug"]
    assignee = "ronykoz"
    parsed_issue = parse_issue({
        "projectCards": {
            "nodes": [{
                "id": "id=",
                "project": {
                    "number": 1,
                    "columns": {
                        "nodes": [{
                            "name": "testing"
                        }]
                    }
                }
            }, {
                "id": "id2=",
                "project": {
                    "number": 2,
                    "columns": {
                        "nodes": [{
                            "name": "Queue"
                        }]
                    }
                }
            }]
        },
        "timelineItems": {
            "__typename":
            "IssueTimelineItemsConnection",
            "nodes": [{
                "willCloseTarget": True,
                "source": {
                    "__typename": "PullRequest",
                    "state": "OPEN",
                    "isDraft": False,
                    "assignees": {
                        "nodes": [{
                            "login": "******"
                        }, {
                            "login": "******"
                        }]
                    },
                    "labels": {
                        "nodes": [{
                            "name": "label"
                        }]
                    },
                    "reviewRequests": {
                        "totalCount": 0
                    },
                    "reviews": {
                        "totalCount": 3
                    },
                    "number": 1,
                    "reviewDecision": "APPROVED"
                }
            }]
        },
        "title": title,
        "id": issue_id,
        "number": 1,
        "milestone": {
            "title": "test"
        },
        "labels": {
            "edges": [{
                "node": {
                    "name": labels[0]
                }
            }, {
                "node": {
                    "name": labels[1]
                }
            }, {
                "node": {
                    "name": labels[2]
                }
            }]
        },
        "assignees": {
            "edges": [{
                "node": {
                    "login": assignee
                }
            }]
        }
    })
    assert parsed_issue['id'] == issue_id
    assert parsed_issue['title'] == title
    assert parsed_issue['labels'] == labels
    assert parsed_issue['assignees'] == [assignee]
    assert parsed_issue['milestone'] == "test"
    assert parsed_issue['number'] == 1
def test_issue_params():
    issue_id = "=asdf=sdf="
    title = "issue name"
    labels = ["HighEffort", "Low", "bug"]
    assignee = "ronykoz"
    issue = Issue(**parse_issue({
        "projectCards": {
            "nodes": [{
                "id": "id=",
                "project": {
                    "number": 1,
                    "columns": {
                        "nodes": [{
                            "name": "testing"
                        }]
                    }
                }
            }, {
                "id": "id2=",
                "project": {
                    "number": 2,
                    "columns": {
                        "nodes": [{
                            "name": "Queue"
                        }]
                    }
                }
            }]
        },
        "timelineItems": {
            "__typename":
            "IssueTimelineItemsConnection",
            "nodes": [{
                "willCloseTarget": True,
                "source": {
                    "__typename": "PullRequest",
                    "state": "OPEN",
                    "isDraft": False,
                    "assignees": {
                        "nodes": [{
                            "login": "******"
                        }, {
                            "login": "******"
                        }]
                    },
                    "labels": {
                        "nodes": [{
                            "name": "label"
                        }]
                    },
                    "reviewRequests": {
                        "totalCount": 0
                    },
                    "reviews": {
                        "totalCount": 3
                    },
                    "number": 1,
                    "reviewDecision": "APPROVED"
                }
            }]
        },
        "title": title,
        "id": issue_id,
        "number": 1,
        "milestone": {
            "title": "test"
        },
        "labels": {
            "edges": [{
                "node": {
                    "name": labels[0]
                }
            }, {
                "node": {
                    "name": labels[1]
                }
            }, {
                "node": {
                    "name": labels[2]
                }
            }]
        },
        "assignees": {
            "edges": [{
                "node": {
                    "login": assignee
                }
            }]
        }
    }))

    assert issue.id == issue_id
    assert issue.title == title
    assert issue.number == 1
    assert sorted(issue.labels) == sorted(labels)
    assert issue.priority_rank == 1
    assert issue.milestone == "test"

    assert sorted(issue.get_associated_project()) == [1, 2]

    assert issue.get_card_id_from_project(1) == 'id='
    assert issue.get_card_id_from_project(2) == 'id2='
    assert issue.get_card_id_from_project(3) is None

    assert issue.pull_request.number == 1
    assert issue.pull_request.assignees == ['test', 'test2']