def test_version_by_tag_with_commit_version_number_should_call_correct_functions( mocker, ): mocker.patch( "semantic_release.cli.config.get", wrapped_config_get( version_source="tag", commit_version_number=True, ), ) mock_set_new_version = mocker.patch("semantic_release.cli.set_new_version") mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mock_commit_new_version = mocker.patch( "semantic_release.cli.commit_new_version") mock_new_version = mocker.patch("semantic_release.cli.get_new_version", return_value="2.0.0") mock_evaluate_bump = mocker.patch( "semantic_release.cli.evaluate_version_bump", return_value="major") mock_current_version = mocker.patch( "semantic_release.cli.get_current_version", return_value="1.2.3") version() mock_current_version.assert_called_once_with() mock_evaluate_bump.assert_called_once_with("1.2.3", None) mock_new_version.assert_called_once_with("1.2.3", "major") mock_set_new_version.assert_called_once_with("2.0.0") mock_commit_new_version.assert_called_once_with("2.0.0") mock_tag_new_version.assert_called_once_with("2.0.0")
def test_version_by_commit_without_tag_should_call_correct_functions(mocker): mocker.patch( "semantic_release.cli.config.get", wrapped_config_get(version_source="commit", tag_commit=False), ) mock_set_new_version = mocker.patch("semantic_release.cli.set_new_version") mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mock_commit_new_version = mocker.patch( "semantic_release.cli.commit_new_version") mock_new_version = mocker.patch("semantic_release.cli.get_new_version", return_value="2.0.0") mock_evaluate_bump = mocker.patch( "semantic_release.cli.evaluate_version_bump", return_value="major") mock_current_version = mocker.patch( "semantic_release.cli.get_current_version", return_value="1.2.3") mock_current_release_version = mocker.patch( "semantic_release.cli.get_current_release_version", return_value="1.2.3") version() mock_current_version.assert_called_once() mock_current_release_version.assert_called_once() mock_evaluate_bump.assert_called_once_with("1.2.3", None) mock_new_version.assert_called_once_with("1.2.3", "1.2.3", "major", False) mock_set_new_version.assert_called_once_with("2.0.0") mock_commit_new_version.assert_called_once_with("2.0.0") assert not mock_tag_new_version.called
def test_version_check_build_status_not_called_if_disabled(mocker): mock_check_build_status = mocker.patch("semantic_release.cli.check_build_status") mocker.patch("semantic_release.cli.config.get", lambda *x, **y: False) mocker.patch("semantic_release.cli.tag_new_version") mocker.patch("semantic_release.cli.evaluate_version_bump", lambda *x: "major") mocker.patch("semantic_release.cli.commit_new_version") mocker.patch("semantic_release.cli.set_new_version") version() assert not mock_check_build_status.called
def test_noop_mode(mocker): mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mock_set_new = mocker.patch("semantic_release.cli.commit_new_version") mock_commit_new = mocker.patch("semantic_release.cli.set_new_version") mocker.patch("semantic_release.cli.evaluate_version_bump", lambda *x: "major") version(noop=True) assert not mock_set_new.called assert not mock_commit_new.called assert not mock_tag_new_version.called
def test_version_retry_and_giterror(mocker): mocker.patch("semantic_release.cli.get_current_version", mock.Mock(side_effect=GitError())) result = version(retry=True) assert not result
def test_version_by_commit_check_build_status_succeeds(mocker): mocker.patch("semantic_release.cli.config.get", lambda *x, **y: True) mock_check_build_status = mocker.patch( "semantic_release.cli.check_build_status", return_value=True) mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mocker.patch("semantic_release.cli.evaluate_version_bump", lambda *x: "major") mock_commit_new = mocker.patch("semantic_release.cli.commit_new_version") mock_set_new = mocker.patch("semantic_release.cli.set_new_version") version() assert mock_check_build_status.called assert mock_set_new.called assert mock_commit_new.called assert mock_tag_new_version.called
def test_version_by_tag_check_build_status_succeeds(mocker): mocker.patch( "semantic_release.cli.config.get", wrapped_config_get( version_source="tag", commit_version_number=False, check_build_status=True, ), ) mock_check_build_status = mocker.patch( "semantic_release.cli.check_build_status", return_value=True ) mock_set_new_version = mocker.patch("semantic_release.cli.set_new_version") mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mocker.patch("semantic_release.cli.evaluate_version_bump", lambda *x: "major") version() assert mock_check_build_status.called assert mock_set_new_version.called assert mock_tag_new_version.called
def test_version_no_change(mocker, runner): mock_tag_new_version = mocker.patch("semantic_release.cli.tag_new_version") mock_commit_new_version = mocker.patch( "semantic_release.cli.commit_new_version") mock_set_new_version = mocker.patch("semantic_release.cli.set_new_version") mock_new_version = mocker.patch("semantic_release.cli.get_new_version", return_value="1.2.3") mock_evaluate_bump = mocker.patch( "semantic_release.cli.evaluate_version_bump", return_value=None) mock_current_version = mocker.patch( "semantic_release.cli.get_current_version", return_value="1.2.3") version() mock_current_version.assert_called_once_with() mock_evaluate_bump.assert_called_once_with("1.2.3", None) mock_new_version.assert_called_once_with("1.2.3", None) assert not mock_set_new_version.called assert not mock_commit_new_version.called assert not mock_tag_new_version.called
def test_version_retry(mocker): mock_get_current = mocker.patch("semantic_release.cli.get_current_version", return_value="current") mock_evaluate_bump = mocker.patch( "semantic_release.cli.evaluate_version_bump", return_value="patch") mock_get_new = mocker.patch("semantic_release.cli.get_new_version", return_value="new") mocker.patch("semantic_release.cli.config.get", lambda *x: False) result = version(noop=False, retry=True, force_level=False) assert result mock_get_current.assert_called_once_with() mock_evaluate_bump.assert_called_once_with("current", False) mock_get_new.assert_called_once_with("current", "patch")
def test_version_retry(mocker): mock_get_current = mocker.patch('semantic_release.cli.get_current_version', return_value='current') mock_evaluate_bump = mocker.patch( 'semantic_release.cli.evaluate_version_bump', return_value='patch') mock_get_new = mocker.patch('semantic_release.cli.get_new_version', return_value='new') mocker.patch('semantic_release.cli.config.getboolean', lambda *x: False) result = version(noop=False, retry=True, force_level=False) assert result mock_get_current.assert_called_once_with() mock_evaluate_bump.assert_called_once_with('current', False) mock_get_new.assert_called_once_with('current', 'patch')