Пример #1
0
def domain_prs() -> List[pr.PullRequest]:
    """Pull requests fixture."""
    prs = [
        pr.PullRequest(
            "my title",
            "my body",
            {"testing"},
            False,
            "",
            False,
            "main",
            "branch",
            True,
        ),
        pr.PullRequest(
            "my title",
            "my body",
            set(),
            True,
            "issue title",
            True,
            "main",
            "branch",
            True,
        ),
    ]
    return prs
Пример #2
0
def test_create_pull_requests(mock_inquirer_prompt: MockerFixture) -> None:
    """It returns pull request."""
    mock_inquirer_prompt.return_value = {
        "title": "my title",
        "body": "my body",
        "labels": "testing,refactor",
        "confirmation": True,
        "link": "issue title",
        "inherit_labels": True,
        "head": "main",
        "base": "branch",
        "draft": False,
        "correct": True,
    }
    result = p.InquirerPrompter.create_pull_requests(["staticdev/omg"])
    expected = pr.PullRequest(
        "my title",
        "my body",
        {"testing", "refactor"},
        True,
        "issue title",
        True,
        "main",
        "branch",
        False,
    )

    assert result == expected
Пример #3
0
def test_create_pull_requests_no_labels(mock_inquirer_prompt: MockerFixture) -> None:
    """It returns pull request."""
    mock_inquirer_prompt.return_value = {
        "title": "my title",
        "body": "my body",
        "labels": "",
        "confirmation": True,
        "issues_title_query": "issue title",
        "inherit_labels": True,
        "head": "main",
        "base": "branch",
        "draft": False,
        "correct": True,
    }
    result = p.InquirerPrompter.create_pull_requests([REPO])
    expected_pr = pr.PullRequest(
        "my title",
        "my body",
        set(),
        True,
        "issue title",
        True,
        "main",
        "branch",
        False,
    )

    assert result == expected_pr
Пример #4
0
def test_pr_model_init() -> None:
    """Verify model initialization."""
    title = "issue title"
    body = "body description"
    labels = {"testing"}
    link_issues = True
    issues_title_query = "query"
    inherit = True
    head = "master"
    base = "node"
    draft = False
    test_pr = pr.PullRequest(title, body, labels, link_issues,
                             issues_title_query, inherit, head, base, draft)

    assert test_pr.title == title
    assert test_pr.body == body
    assert test_pr.labels == labels
    assert test_pr.link_issues == link_issues
    assert test_pr.issues_title_query == issues_title_query
    assert test_pr.inherit_labels == inherit
    assert test_pr.head == head
    assert test_pr.base == base
    assert test_pr.draft == draft
Пример #5
0
    def create_pull_requests(github_selected_repos: List[str]) -> pr.PullRequest:
        """Prompt questions to create pull requests."""
        questions = [
            inquirer.Text(
                "base",
                message="Write base branch name (destination)",
                default="master",
                validate=val.not_empty_validation,
            ),
            inquirer.Text(
                "head",
                message="Write the head branch name (source)",
                validate=val.not_empty_validation,
            ),
            inquirer.Text(
                "title", message="Write a PR title", validate=val.not_empty_validation
            ),
            inquirer.Text("body", message="Write an PR body [optional]"),
            # inquirer.Confirm(
            #     "draft", message="Do you want to create a draft PR?", default=False
            # ),
            inquirer.Text(
                "labels", message="Write PR labels [optional, separated by comma]"
            ),
            inquirer.Confirm(
                "confirmation",
                message="Do you want to link pull request to issues by title?",
                default=False,
            ),
            inquirer.Text(
                "link",
                message="Write issue title (or part of it)",
                default="",
                validate=val.not_empty_validation,
                ignore=val.ignore_if_not_confirmed,
            ),
            inquirer.Confirm(
                "inherit_labels",
                message="Do you want to add labels inherited from the issues?",
                default=True,
                ignore=val.ignore_if_not_confirmed,
            ),
            inquirer.Confirm(
                "correct",
                message=(
                    "Confirm creation of pull request(s) for the project(s) "
                    f"{github_selected_repos}. Continue?"
                ),
                default=False,
            ),
        ]
        correct = False
        while not correct:
            answers = inquirer.prompt(questions)
            correct = answers["correct"]

        labels = (
            set(label.strip() for label in answers["labels"].split(","))
            if answers["labels"]
            else set()
        )
        return pr.PullRequest(
            answers["title"],
            answers["body"],
            labels,
            answers["confirmation"],
            answers["link"],
            answers["inherit_labels"],
            answers["head"],
            answers["base"],
            False,
        )