Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
def test_publish_giterror_when_posting(mocker):
    mock_get_current = mocker.patch("semantic_release.cli.get_current_version",
                                    return_value="current")
    mock_evaluate = 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")
    mock_get_owner_name = mocker.patch(
        "semantic_release.cli.get_repository_owner_and_name",
        return_value=("owner", "name"),
    )
    mock_ci_check = mocker.patch("semantic_release.ci_checks.check")
    mock_checkout = mocker.patch("semantic_release.cli.checkout")
    mocker.patch("semantic_release.cli.config.get", return_value="my_branch")
    mocker.patch("semantic_release.cli.config.getboolean", return_value=False)
    mock_version = mocker.patch("semantic_release.cli.version")
    mock_get_token = mocker.patch("semantic_release.cli.get_token",
                                  return_value="SUPERTOKEN")
    mock_get_domain = mocker.patch("semantic_release.cli.get_domain",
                                   return_value="domain")
    mock_push = mocker.patch("semantic_release.cli.push_new_version")
    mock_check_token = mocker.patch("semantic_release.cli.check_token",
                                    return_value=True)
    mock_generate = mocker.patch("semantic_release.cli.generate_changelog",
                                 return_value="super changelog")
    mock_markdown = mocker.patch("semantic_release.cli.markdown_changelog",
                                 return_value="super md changelog")
    mock_post = mocker.patch("semantic_release.cli.post_changelog",
                             mock.Mock(side_effect=GitError()))

    publish(noop=False, retry=False, force_level=False)

    mock_get_current.assert_called_once_with()
    mock_evaluate.assert_called_once_with("current", False)
    mock_get_new.assert_called_once_with("current", "patch")
    mock_get_owner_name.assert_called_once_with()
    mock_ci_check.assert_called()
    mock_checkout.assert_called_once_with("my_branch")
    mock_version.assert_called_once_with(noop=False,
                                         retry=False,
                                         force_level=False)
    mock_get_token.assert_called_once_with()
    mock_get_domain.assert_called_once_with()
    mock_push.assert_called_once_with(
        auth_token="SUPERTOKEN",
        owner="owner",
        name="name",
        branch="my_branch",
        domain="domain",
    )
    mock_check_token.assert_called_once_with()
    mock_generate.assert_called_once_with("current", "new")
    mock_markdown.assert_called_once_with("new",
                                          "super changelog",
                                          header=False)
    mock_post.assert_called_once_with("owner", "name", "new",
                                      "super md changelog")
def test_publish_giterror_when_posting(mocker):
    mock_get_current = mocker.patch('semantic_release.cli.get_current_version',
                                    return_value='current')
    mock_evaluate = 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')
    mock_get_owner_name = mocker.patch(
        'semantic_release.cli.get_repository_owner_and_name',
        return_value=('owner', 'name'))
    mock_ci_check = mocker.patch('semantic_release.ci_checks.check')
    mock_checkout = mocker.patch('semantic_release.cli.checkout')
    mocker.patch('semantic_release.cli.config.get', return_value='my_branch')
    mocker.patch('semantic_release.cli.config.getboolean', return_value=False)
    mock_version = mocker.patch('semantic_release.cli.version')
    mock_get_token = mocker.patch('semantic_release.cli.get_token',
                                  return_value='SUPERTOKEN')
    mock_get_domain = mocker.patch('semantic_release.cli.get_domain',
                                   return_value='domain')
    mock_push = mocker.patch('semantic_release.cli.push_new_version')
    mock_check_token = mocker.patch('semantic_release.cli.check_token',
                                    return_value=True)
    mock_generate = mocker.patch('semantic_release.cli.generate_changelog',
                                 return_value='super changelog')
    mock_markdown = mocker.patch('semantic_release.cli.markdown_changelog',
                                 return_value='super md changelog')
    mock_post = mocker.patch('semantic_release.cli.post_changelog',
                             mock.Mock(side_effect=GitError()))

    publish(noop=False, retry=False, force_level=False)

    mock_get_current.assert_called_once_with()
    mock_evaluate.assert_called_once_with('current', False)
    mock_get_new.assert_called_once_with('current', 'patch')
    mock_get_owner_name.assert_called_once_with()
    mock_ci_check.assert_called()
    mock_checkout.assert_called_once_with('my_branch')
    mock_version.assert_called_once_with(noop=False,
                                         retry=False,
                                         force_level=False)
    mock_get_token.assert_called_once_with()
    mock_get_domain.assert_called_once_with()
    mock_push.assert_called_once_with(auth_token='SUPERTOKEN',
                                      owner='owner',
                                      name='name',
                                      branch='my_branch',
                                      domain='domain')
    mock_check_token.assert_called_once_with()
    mock_generate.assert_called_once_with('current', 'new')
    mock_markdown.assert_called_once_with('new',
                                          'super changelog',
                                          header=False)
    mock_post.assert_called_once_with('owner', 'name', 'new',
                                      'super md changelog')
Ejemplo n.º 4
0
def test_publish_giterror_when_posting(mocker):
    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")
    mock_evaluate = 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")
    mock_get_owner_name = mocker.patch(
        "semantic_release.cli.get_repository_owner_and_name",
        return_value=("owner", "name"),
    )
    mock_ci_check = mocker.patch("semantic_release.ci_checks.check")
    mock_checkout = mocker.patch("semantic_release.cli.checkout")
    mocker.patch(
        "semantic_release.cli.config.get",
        wrapped_config_get(
            branch="my_branch",
            upload_to_repository=False,
            upload_to_release=False,
            remove_dist=False,
        ),
    )
    mock_bump_version = mocker.patch("semantic_release.cli.bump_version")
    mock_should_bump_version = mocker.patch(
        "semantic_release.cli.should_bump_version", return_value=True)
    mock_get_token = mocker.patch("semantic_release.cli.get_token",
                                  return_value="SUPERTOKEN")
    mock_get_domain = mocker.patch("semantic_release.cli.get_domain",
                                   return_value="domain")
    mock_push = mocker.patch("semantic_release.cli.push_new_version")
    mock_check_token = mocker.patch("semantic_release.cli.check_token",
                                    return_value=True)
    mock_generate = mocker.patch("semantic_release.cli.generate_changelog",
                                 return_value="super changelog")
    mock_markdown = mocker.patch("semantic_release.cli.markdown_changelog",
                                 return_value="super md changelog")
    mock_update_changelog_file = mocker.patch(
        "semantic_release.cli.update_changelog_file")
    mock_post = mocker.patch("semantic_release.cli.post_changelog",
                             mock.Mock(side_effect=GitError()))

    publish(noop=False, retry=False, force_level=False)

    mock_current_version.assert_called_once()
    mock_current_release_version.assert_called_once()
    mock_evaluate.assert_called_once_with("1.2.3", False)
    mock_get_new.assert_called_once_with("1.2.3", "1.2.3", "patch", False)
    mock_get_owner_name.assert_called_once_with()
    mock_ci_check.assert_called()
    mock_checkout.assert_called_once_with("my_branch")
    mock_should_bump_version.assert_called_once_with(
        current_version="1.2.3",
        new_version="new",
        current_release_version="1.2.3",
        prerelease=False,
        noop=False,
        retry=False,
    )
    mock_update_changelog_file.assert_called_once_with("new",
                                                       "super md changelog")
    mock_bump_version.assert_called_once_with("new", "patch")
    mock_get_token.assert_called_once_with()
    mock_get_domain.assert_called_once_with()
    mock_push.assert_called_once_with(
        auth_token="SUPERTOKEN",
        owner="owner",
        name="name",
        branch="my_branch",
        domain="domain",
    )
    mock_check_token.assert_called_once_with()
    mock_generate.assert_called_once_with("1.2.3")
    mock_markdown.assert_called_once_with(
        "owner",
        "name",
        "new",
        "super changelog",
        header=False,
        previous_version="1.2.3",
    )
    mock_post.assert_called_once_with("owner", "name", "new",
                                      "super md changelog")