Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cherry-picker: Remove BACKPORT_COMPLETE. UNSET state after finished. #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 17, 2019
Prev Previous commit
Next Next commit
mock the validate_sha
  • Loading branch information
Mariatta committed Mar 17, 2019
commit 8acc8a1fa5f9d179a1ea2545e4c8dd22fd9a8ffb
2 changes: 1 addition & 1 deletion 2 cherry_picker/cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from . import __version__

CREATE_PR_URL_TEMPLATE = (
"https://api.github.com/repos/" "{config[team]}/{config[repo]}/pulls"
"https://api.github.com/repos/{config[team]}/{config[repo]}/pulls"
)
DEFAULT_CONFIG = collections.ChainMap(
{
Expand Down
61 changes: 34 additions & 27 deletions 61 cherry_picker/cherry_picker/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def test_sorted_branch(os_path_exists, config, input_branches, sorted_branches):
],
)
@mock.patch("os.path.exists")
@mock.patch("cherry_picker.cherry_picker.validate_sha")
def test_invalid_branches(os_path_exists, config, input_branches):
os_path_exists.return_value = True
cp = CherryPicker(
Expand All @@ -209,6 +210,7 @@ def test_invalid_branches(os_path_exists, config, input_branches):


@mock.patch("os.path.exists")
@mock.patch("cherry_picker.cherry_picker.validate_sha")
def test_get_cherry_pick_branch(os_path_exists, config):
os_path_exists.return_value = True
branches = ["3.6"]
Expand All @@ -220,21 +222,23 @@ def test_get_cherry_pick_branch(os_path_exists, config):

def test_get_pr_url(config):
branches = ["3.6"]
cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
backport_target_branch = cp.get_cherry_pick_branch("3.6")
expected_pr_url = (
"https://github.com/python/cpython/compare/"
"3.6...mock_user:backport-22a594a-3.6?expand=1"
)
with mock.patch(
"subprocess.check_output",
return_value=b"https://github.com/mock_user/cpython.git",
):
actual_pr_url = cp.get_pr_url("3.6", backport_target_branch)
with mock.patch("cherry_picker.cherry_picker.validate_sha"):

cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
backport_target_branch = cp.get_cherry_pick_branch("3.6")
expected_pr_url = (
"https://github.com/python/cpython/compare/"
"3.6...mock_user:backport-22a594a-3.6?expand=1"
)
with mock.patch(
"subprocess.check_output",
return_value=b"https://github.com/mock_user/cpython.git",
):
actual_pr_url = cp.get_pr_url("3.6", backport_target_branch)

assert actual_pr_url == expected_pr_url
assert actual_pr_url == expected_pr_url


@pytest.mark.parametrize(
Expand All @@ -250,13 +254,15 @@ def test_get_pr_url(config):
)
def test_username(url, config):
branches = ["3.6"]
cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
with mock.patch("subprocess.check_output", return_value=url):
assert cp.username == "mock_user"
with mock.patch("cherry_picker.cherry_picker.validate_sha"):
cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
with mock.patch("subprocess.check_output", return_value=url):
assert cp.username == "mock_user"


@mock.patch("cherry_picker.cherry_picker.validate_sha")
def test_get_updated_commit_message(config):
branches = ["3.6"]
cp = CherryPicker(
Expand All @@ -274,15 +280,16 @@ def test_get_updated_commit_message(config):
def test_get_updated_commit_message_without_links_replacement(config):
config["fix_commit_msg"] = False
branches = ["3.6"]
cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
with mock.patch(
"subprocess.check_output", return_value=b"bpo-123: Fix Spam Module (#113)"
):
actual_commit_message = cp.get_commit_message(
"22a594a0047d7706537ff2ac676cdc0f1dcb329c"
with mock.patch("cherry_picker.cherry_picker.validate_sha"):
cp = CherryPicker(
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
)
with mock.patch(
"subprocess.check_output", return_value=b"bpo-123: Fix Spam Module (#113)"
):
actual_commit_message = cp.get_commit_message(
"22a594a0047d7706537ff2ac676cdc0f1dcb329c"
)
assert actual_commit_message == "bpo-123: Fix Spam Module (#113)"


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.