Esempio n. 1
0
def test_incr_default(runner):
    old_version = "v201701.0999-alpha"
    initial_version = config._initial_version()

    result = runner.invoke(cli.cli, ['test', "-vv", old_version])
    assert result.exit_code == 0
    new_version = initial_version.replace(".0001-alpha", ".11000-alpha")
    assert f"Version: {new_version}\n" in result.output
Esempio n. 2
0
def test_novcs_pyproject_init(runner):
    _add_project_files("README.md", "pyproject.toml")
    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 0

    with pl.Path("pyproject.toml").open(mode="r", encoding="utf-8") as fh:
        cfg_content = fh.read()

    base_str = config.DEFAULT_TOML_BASE_TMPL.format(
        initial_version=config._initial_version())
    assert base_str in cfg_content
    assert config.DEFAULT_TOML_README_MD_STR in cfg_content

    result = runner.invoke(cli.cli, ['show'])
    assert result.exit_code == 0
    assert f"Current Version: {config._initial_version()}\n" in result.output
    assert f"PEP440         : {config._initial_version_pep440()}\n" in result.output
Esempio n. 3
0
def test_novcs_nocfg_init(runner, caplog):
    _add_project_files("README.md")
    # dry mode test
    result = runner.invoke(cli.cli, ['init', "-vv", "--dry"])
    assert result.exit_code == 0
    assert not os.path.exists("pycalver.toml")

    # check logging
    assert len(caplog.records) == 1
    log = caplog.records[0]
    assert log.levelname == 'WARNING'
    assert "File not found" in log.message

    # non dry mode
    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 0

    # check logging
    assert len(caplog.records) == 2
    log = caplog.records[1]
    assert log.levelname == 'WARNING'
    assert "File not found" in log.message

    assert os.path.exists("pycalver.toml")
    with pl.Path("pycalver.toml").open(mode="r", encoding="utf-8") as fh:
        cfg_content = fh.read()

    base_str = config.DEFAULT_TOML_BASE_TMPL.format(
        initial_version=config._initial_version())
    assert base_str in cfg_content
    assert config.DEFAULT_TOML_README_MD_STR in cfg_content

    result = runner.invoke(cli.cli, ['show', "-vv"])
    assert result.exit_code == 0
    assert f"Current Version: {config._initial_version()}\n" in result.output
    assert f"PEP440         : {config._initial_version_pep440()}\n" in result.output

    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 1

    # check logging
    assert len(caplog.records) == 3
    log = caplog.records[2]
    assert log.levelname == 'ERROR'
    assert "Configuration already initialized" in log.message
Esempio n. 4
0
def test_hg_bump(runner):
    _add_project_files("README.md")
    _vcs_init("hg")

    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 0

    sh("hg", "add", "pycalver.toml")
    sh("hg", "commit", "-m", "initial commit")

    result = runner.invoke(cli.cli, ['bump', "-vv"])
    assert result.exit_code == 0

    calver = config._initial_version()[:7]

    with pl.Path("README.md").open() as fh:
        content = fh.read()
        assert calver + ".0002-alpha !\n" in content
Esempio n. 5
0
def test_hg_tag_eval(runner):
    _add_project_files("README.md")
    _vcs_init("hg")

    # This will set a version that is older than the version tag
    # we set in the vcs, which should take precedence.
    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 0
    initial_version = config._initial_version()
    tag_version = initial_version.replace(".0001-alpha", ".0123-beta")
    tag_version_pep440 = tag_version[1:7] + ".123b0"

    sh("hg", "tag", tag_version, "--message", f"bump version to {tag_version}")

    result = runner.invoke(cli.cli, ['show', "-vv"])
    assert result.exit_code == 0
    assert f"Current Version: {tag_version}\n" in result.output
    assert f"PEP440         : {tag_version_pep440}\n" in result.output
Esempio n. 6
0
def test_novcs_bump(runner):
    _add_project_files("README.md")

    result = runner.invoke(cli.cli, ['init', "-vv"])
    assert result.exit_code == 0

    result = runner.invoke(cli.cli, ['bump', "-vv"])
    assert result.exit_code == 0

    calver = config._initial_version()[:7]

    with pl.Path("README.md").open() as fh:
        content = fh.read()
        assert calver + ".0002-alpha !\n" in content
        assert calver[1:] + ".2a0 !\n" in content

    result = runner.invoke(cli.cli, ['bump', "-vv", "--release", "beta"])
    assert result.exit_code == 0

    with pl.Path("README.md").open() as fh:
        content = fh.read()
        assert calver + ".0003-beta !\n" in content
        assert calver[1:] + ".3b0 !\n" in content