def test_update_remote_patches_branch_with_dev_mode(mock_repo): """ GIVEN Rebaser initialized correctly WITH dev_mode set to true WHEN update_remote_patches_branch is called THEN tag.delete is not called AND git.push is called with -n argument for dry-run """ mock_repo.branch.cherry_on_head_only.return_value = True rebaser = Rebaser(mock_repo, "my_branch", "my_commit", "my_remote", "2019", dev_mode=True, release='2.1') rebaser.update_remote_patches_branch() # Tag not deleted, and pushed with -n for dry-run assert mock_repo.tag.delete.called is False assert mock_repo.git.push.called is True expected = [(("-n", "my_remote", "private-rebaser-2.1-2019-previous"), ), (("-nf", "--follow-tags", "my_remote", "my_branch"), )] assert mock_repo.git.push.call_args_list == expected
def test_update_remote_patches_branch_no_changes_with_remote(mock_repo): """ GIVEN Rebaser initialized correctly WHEN update_remote_patches_branch is called AND cherry_on_head_only returns false (indicating the local and remote branches have no differences) THEN tag.delete is called AND git.push is not called """ mock_repo.branch.cherry_on_head_only.return_value = False rebaser = Rebaser(mock_repo, "my_branch", "my_commit", "my_remote", "my_tstamp", dev_mode=True) rebaser.update_remote_patches_branch() mock_repo.tag.delete.assert_called_once() assert mock_repo.git.push.called is False
def test_update_remote_patches_branch_no_changes_and_commit_present(mock_repo): """ GIVEN Rebaser initialized correctly WHEN update_remote_patches_branch is called AND cherry_on_head_only returns false (indicating the local and remote branches have no differences) AND branch.remote_contains returns true THEN git.push is not called """ mock_repo.branch.cherry_on_head_only.return_value = False mock_repo.branch.remote_contains.return_value = True rebaser = Rebaser(mock_repo, "my_branch", "my_commit", "my_remote", "my_tstamp", dev_mode=True) rebaser.update_remote_patches_branch() assert mock_repo.git.push.called is False