diff --git a/cherry_picker/test.py b/cherry_picker/test.py index 5eb271f..efcb910 100644 --- a/cherry_picker/test.py +++ b/cherry_picker/test.py @@ -56,6 +56,12 @@ def git_init(): return lambda: subprocess.run(git_init_cmd, check=True) +@pytest.fixture +def git_remote(): + git_remote_cmd = "git", "remote" + return lambda *extra_args: (subprocess.run(git_remote_cmd + extra_args, check=True)) + + @pytest.fixture def git_add(): git_add_cmd = "git", "add" @@ -217,6 +223,27 @@ def test_get_cherry_pick_branch(os_path_exists, config): assert cp.get_cherry_pick_branch("3.6") == "backport-22a594a-3.6" +@pytest.mark.parametrize("remote_name", ("upstream", "origin", "python")) +def test_upstream_name(remote_name, config, tmp_git_repo_dir, git_remote): + upstream_remote = None + if remote_name == "python": + upstream_remote = "python" + git_remote("add", remote_name, "https://github.com/python/cpython.git") + if remote_name != "origin": + git_remote("add", "origin", "https://github.com/miss-islington/cpython.git") + + branches = ["3.6"] + with mock.patch("cherry_picker.cherry_picker.validate_sha", return_value=True): + cp = CherryPicker( + "origin", + "22a594a0047d7706537ff2ac676cdc0f1dcb329c", + branches, + config=config, + upstream_remote=upstream_remote, + ) + assert cp.upstream == remote_name + + def test_get_pr_url(config): branches = ["3.6"]