Esempio n. 1
0
def domain_mprs() -> List[mpr.PullRequestMerge]:
    """Pull request merge fixture."""
    mprs = [
        mpr.PullRequestMerge("branch", "main", "org name", False),
        mpr.PullRequestMerge("branch-2", "main", "org name", True),
    ]
    return mprs
Esempio n. 2
0
def test_pr_model_init() -> None:
    """Verify model initialization."""
    head = "master"
    base = "node"
    prefix = "omg"
    delete = False
    test_prm = prm.PullRequestMerge(base, head, prefix, delete)

    assert test_prm.base == base
    assert test_prm.head == head
    assert test_prm.prefix == prefix
    assert test_prm.delete_branch == delete
Esempio n. 3
0
def test_merge_pull_requests(mock_inquirer_prompt: MockerFixture) -> None:
    """It returns pull request merge."""
    mock_inquirer_prompt.return_value = {
        "base": "branch",
        "head": "main",
        "prefix": "org name",
        "delete_branch": True,
        "correct": True,
    }
    result = p.InquirerPrompter.merge_pull_requests("staticdev", [REPO])
    expected = prm.PullRequestMerge("branch", "main", "org name", True)

    assert result == expected
Esempio n. 4
0
 def merge_pull_requests(
     github_username: str, github_selected_repos: List[str]
 ) -> prm.PullRequestMerge:
     """Prompt questions to merge 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(
             "prefix",
             message="Write base user or organization name from PR head",
             default=github_username,
             validate=val.not_empty_validation,
         ),
         inquirer.Confirm(
             "delete_branch",
             message="Do you want to delete head branch on merge?",
             default=False,
         ),
         inquirer.Confirm(
             "correct",
             message=(
                 "Confirm merging 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"]
     return prm.PullRequestMerge(
         answers["base"],
         answers["head"],
         answers["prefix"],
         answers["delete_branch"],
     )
Esempio n. 5
0
def domain_mpr() -> mpr.PullRequestMerge:
    """Pull request merge fixture."""
    return mpr.PullRequestMerge("branch", "main", "org name", False)