def test_promoting_final(method):
    version = Version(1, 2, 3)
    with pytest.raises(AssertionError):
        # noinspection PyArgumentList
        method(version)
Пример #2
0
from os import path

from devops.utils.version import Version


PROJECT_NAME = "python-clean-architecture"
PACKAGE_NAME = "pca"
VERSION = Version(0, 0, 6)

PACKAGE_DIR = path.dirname(__file__)
PROJECT_DIR = path.dirname(PACKAGE_DIR)
def test_as_git_tag(params, expected):
    assert Version(*params).as_git_tag() == expected
def test_bumping_non_final(method):
    version = Version(1, 2, 3, 'a', 3)
    with pytest.raises(AssertionError):
        method(version)
def test_as_string(params, expected):
    assert Version(*params).as_string() == expected
def test_repr(params, expected):
    assert repr(Version(*params)) == expected
def test_as_release(params, expected):
    assert Version(*params).as_release() == expected
        method(version)


@pytest.mark.parametrize("method", [
    Version.bump_pre,
    Version.promote_pre,
])
def test_promoting_final(method):
    version = Version(1, 2, 3)
    with pytest.raises(AssertionError):
        # noinspection PyArgumentList
        method(version)


@pytest.mark.parametrize("version, add_pre, expected", [
    (Version(1, 2, 3), True, Version(2, 0, 0, 'a', 0)),
    (Version(1, 2, 3), False, Version(2, 0, 0)),
    (Version(0, 2, None), True, Version(1, 0, None, 'a', 0)),
    (Version(0, 2, None), False, Version(1, 0)),
])
def test_bump_major(version, add_pre, expected):
    assert version.bump_major(add_pre=add_pre) == expected


@pytest.mark.parametrize("version, add_pre, expected", [
    (Version(0, 0), True, Version(0, 1, None, 'a', 0)),
    (Version(0, 0), False, Version(0, 1)),
    (Version(1, 2, 3), True, Version(1, 3, 0, 'a', 0)),
    (Version(1, 2, 3), False, Version(1, 3, 0)),
    (Version(0, 2, None), True, Version(0, 3, None, 'a', 0)),
    (Version(0, 2, None), False, Version(0, 3)),
Пример #9
0
    [
        Version.bump_pre,
        Version.promote_pre,
    ],
)
def test_promoting_final(method):
    version = Version(1, 2, 3)
    with pytest.raises(AssertionError):
        # noinspection PyArgumentList
        method(version)


@pytest.mark.parametrize(
    "version, add_pre, expected",
    [
        (Version(1, 2, 3), True, Version(2, 0, 0, "a", 0)),
        (Version(1, 2, 3), False, Version(2, 0, 0)),
        (Version(0, 2, None), True, Version(1, 0, None, "a", 0)),
        (Version(0, 2, None), False, Version(1, 0)),
    ],
)
def test_bump_major(version, add_pre, expected):
    assert version.bump_major(add_pre=add_pre) == expected


@pytest.mark.parametrize(
    "version, add_pre, expected",
    [
        (Version(0, 0), True, Version(0, 1, None, "a", 0)),
        (Version(0, 0), False, Version(0, 1)),
        (Version(1, 2, 3), True, Version(1, 3, 0, "a", 0)),