Skip to content

Commit 5b33950

Browse files
committed
✅ Add tests for two-stage methods
1 parent e1428ae commit 5b33950

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

cherry_picker/cherry_picker/test.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,34 @@ def test_paused_flow(tmp_git_repo_dir, git_add, git_commit):
452452

453453
reset_stored_config_ref()
454454
assert load_val_from_git_cfg('config_path') is None
455+
456+
457+
@pytest.mark.parametrize(
458+
'method_name,start_state,end_state',
459+
(
460+
('fetch_upstream', 'FETCHING_UPSTREAM', 'FETCHED_UPSTREAM'),
461+
(
462+
'checkout_default_branch',
463+
'CHECKING_OUT_DEFAULT_BRANCH', 'CHECKED_OUT_DEFAULT_BRANCH',
464+
),
465+
),
466+
)
467+
def test_start_end_states(
468+
method_name, start_state, end_state,
469+
tmp_git_repo_dir, git_add, git_commit,
470+
):
471+
assert get_state() == 'UNSET'
472+
473+
with mock.patch(
474+
'cherry_picker.cherry_picker.validate_sha',
475+
return_value=True,
476+
):
477+
cherry_picker = CherryPicker('origin', 'xxx', [])
478+
assert get_state() == 'UNSET'
479+
480+
def _fetch(cmd):
481+
assert get_state() == start_state
482+
483+
with mock.patch.object(cherry_picker, 'run_cmd', _fetch):
484+
getattr(cherry_picker, method_name)()
485+
assert get_state() == end_state

0 commit comments

Comments
 (0)