Ejemplo n.º 1
0
def test_get_matching_column():
    config = Configuration(os.path.join(MOCK_FOLDER_PATH, 'conf.ini'))
    config.load_properties()

    issue_queue = Issue(id="1", title="issue 1", number=1)
    assert Project.get_matching_column(issue_queue, config) == 'Queue'

    issue_in_progress = Issue(id="1", title="issue 1", number=1)
    issue_in_progress.add_assignee("Rony")
    assert Project.get_matching_column(issue_in_progress, config) == ''
    issue_in_progress.add_label("Testing")
    assert Project.get_matching_column(issue_in_progress,
                                       config) == 'In progress'

    issue_review_in_progress = Issue(id="1", title="issue 1", number=1)
    issue_review_in_progress.add_assignee("Rony")

    class MockPullRequest(object):
        review_requested = True
        review_completed = False

    issue_review_in_progress.pull_request = MockPullRequest()

    assert Project.get_matching_column(issue_review_in_progress,
                                       config) == 'Review in progress'

    issue_docs = Issue(id="1", title="issue 1", number=1)
    issue_docs.add_assignee("Rony")

    class MockPullRequest2(object):
        review_requested = True
        review_completed = True
        assignees = "ronykoz"

    issue_docs.pull_request = MockPullRequest2()

    assert Project.get_matching_column(issue_docs,
                                       config) == 'Waiting for Docs'

    class MockPullRequest3(object):
        review_requested = True
        review_completed = True
        assignees = "someone"

    issue_docs.pull_request = MockPullRequest3()

    assert Project.get_matching_column(issue_docs,
                                       config) == 'Review in progress'

    # faulty field from issues
    config.column_to_rules["Waiting for Docs"] = {
        "issue.not_existent": "field"
    }
    assert Project.get_matching_column(issue_docs,
                                       config) == 'Review in progress'
Ejemplo n.º 2
0
def test_add_details():
    issue_id = "=asdf=sdf="
    title = "issue name"
    labels = ["HighEffort", "Low", "bug"]
    assignee = "ronykoz"
    milestone = "test"

    issue = Issue(id=issue_id,
                  number=1,
                  title=title,
                  labels=labels,
                  assignees=[assignee],
                  milestone=milestone)

    issue.add_assignee("another one")
    assert sorted(issue.assignees) == sorted([assignee, "another one"])

    labels_new = deepcopy(labels)
    issue.add_label("label")
    labels_new.append("label")
    assert sorted(issue.labels) == sorted(labels_new)