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

Commit 8acc8a1

Browse filesBrowse files
committed
mock the validate_sha
1 parent 36f0732 commit 8acc8a1
Copy full SHA for 8acc8a1

File tree

2 files changed

+35
-28
lines changed
Filter options

2 files changed

+35
-28
lines changed

‎cherry_picker/cherry_picker/cherry_picker.py

Copy file name to clipboardExpand all lines: cherry_picker/cherry_picker/cherry_picker.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from . import __version__
1818

1919
CREATE_PR_URL_TEMPLATE = (
20-
"https://api.github.com/repos/" "{config[team]}/{config[repo]}/pulls"
20+
"https://api.github.com/repos/{config[team]}/{config[repo]}/pulls"
2121
)
2222
DEFAULT_CONFIG = collections.ChainMap(
2323
{

‎cherry_picker/cherry_picker/test.py

Copy file name to clipboardExpand all lines: cherry_picker/cherry_picker/test.py
+34-27Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def test_sorted_branch(os_path_exists, config, input_branches, sorted_branches):
196196
],
197197
)
198198
@mock.patch("os.path.exists")
199+
@mock.patch("cherry_picker.cherry_picker.validate_sha")
199200
def test_invalid_branches(os_path_exists, config, input_branches):
200201
os_path_exists.return_value = True
201202
cp = CherryPicker(
@@ -209,6 +210,7 @@ def test_invalid_branches(os_path_exists, config, input_branches):
209210

210211

211212
@mock.patch("os.path.exists")
213+
@mock.patch("cherry_picker.cherry_picker.validate_sha")
212214
def test_get_cherry_pick_branch(os_path_exists, config):
213215
os_path_exists.return_value = True
214216
branches = ["3.6"]
@@ -220,21 +222,23 @@ def test_get_cherry_pick_branch(os_path_exists, config):
220222

221223
def test_get_pr_url(config):
222224
branches = ["3.6"]
223-
cp = CherryPicker(
224-
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
225-
)
226-
backport_target_branch = cp.get_cherry_pick_branch("3.6")
227-
expected_pr_url = (
228-
"https://github.com/python/cpython/compare/"
229-
"3.6...mock_user:backport-22a594a-3.6?expand=1"
230-
)
231-
with mock.patch(
232-
"subprocess.check_output",
233-
return_value=b"https://github.com/mock_user/cpython.git",
234-
):
235-
actual_pr_url = cp.get_pr_url("3.6", backport_target_branch)
225+
with mock.patch("cherry_picker.cherry_picker.validate_sha"):
226+
227+
cp = CherryPicker(
228+
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
229+
)
230+
backport_target_branch = cp.get_cherry_pick_branch("3.6")
231+
expected_pr_url = (
232+
"https://github.com/python/cpython/compare/"
233+
"3.6...mock_user:backport-22a594a-3.6?expand=1"
234+
)
235+
with mock.patch(
236+
"subprocess.check_output",
237+
return_value=b"https://github.com/mock_user/cpython.git",
238+
):
239+
actual_pr_url = cp.get_pr_url("3.6", backport_target_branch)
236240

237-
assert actual_pr_url == expected_pr_url
241+
assert actual_pr_url == expected_pr_url
238242

239243

240244
@pytest.mark.parametrize(
@@ -250,13 +254,15 @@ def test_get_pr_url(config):
250254
)
251255
def test_username(url, config):
252256
branches = ["3.6"]
253-
cp = CherryPicker(
254-
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
255-
)
256-
with mock.patch("subprocess.check_output", return_value=url):
257-
assert cp.username == "mock_user"
257+
with mock.patch("cherry_picker.cherry_picker.validate_sha"):
258+
cp = CherryPicker(
259+
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
260+
)
261+
with mock.patch("subprocess.check_output", return_value=url):
262+
assert cp.username == "mock_user"
258263

259264

265+
@mock.patch("cherry_picker.cherry_picker.validate_sha")
260266
def test_get_updated_commit_message(config):
261267
branches = ["3.6"]
262268
cp = CherryPicker(
@@ -274,15 +280,16 @@ def test_get_updated_commit_message(config):
274280
def test_get_updated_commit_message_without_links_replacement(config):
275281
config["fix_commit_msg"] = False
276282
branches = ["3.6"]
277-
cp = CherryPicker(
278-
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
279-
)
280-
with mock.patch(
281-
"subprocess.check_output", return_value=b"bpo-123: Fix Spam Module (#113)"
282-
):
283-
actual_commit_message = cp.get_commit_message(
284-
"22a594a0047d7706537ff2ac676cdc0f1dcb329c"
283+
with mock.patch("cherry_picker.cherry_picker.validate_sha"):
284+
cp = CherryPicker(
285+
"origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", branches, config=config
285286
)
287+
with mock.patch(
288+
"subprocess.check_output", return_value=b"bpo-123: Fix Spam Module (#113)"
289+
):
290+
actual_commit_message = cp.get_commit_message(
291+
"22a594a0047d7706537ff2ac676cdc0f1dcb329c"
292+
)
286293
assert actual_commit_message == "bpo-123: Fix Spam Module (#113)"
287294

288295

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.