Example #1
0
def test_check_version_os_no_params() -> None:
    assert [
        *_check_version(
            "1.2.3",
            "site_version",
            ("ignore", {}),
            State.WARN,
        )
    ] == [Result(state=State.OK, summary="Version: 1.2.3")]
Example #2
0
def test_check_version_site_mismatch(fail_state: State) -> None:
    assert [*_check_version(
        "1.2.3",
        "1.2.2",
        ("site", {}),
        fail_state,
    )] == [
        Result(state=fail_state, summary="Version: 1.2.3 (expected 1.2.2)"),
    ]
Example #3
0
def test_check_version_at_least_dict_empty():
    spec: dict[str, str] = {}
    assert [
        *_check_version(
            "1.2.3",
            "site.version",
            ("at_least", spec),
            State.WARN,
        )
    ] == [Result(state=State.OK, summary="Version: 1.2.3")]
Example #4
0
def test_check_version_match() -> None:
    assert [
        *_check_version(
            "1.2.3",
            "2.1.0",
            ("specific", {
                "literal": "1.2.3"
            }),
            State.WARN,
        )
    ] == [Result(state=State.OK, summary="Version: 1.2.3")]
Example #5
0
def test_check_version_os_no_values() -> None:
    assert not [
        *_check_version(
            None,
            "site_version",
            ("specific", {
                "literal": "irrelevant"
            }),
            State.WARN,
        )
    ]
Example #6
0
def test_check_version_at_least_success():
    assert [
        *_check_version(
            "1.2.3",
            "site.version",
            ("at_least", {
                "release": "1.1.0"
            }),
            State.WARN,
        )
    ] == [Result(state=State.OK, summary="Version: 1.2.3")]
Example #7
0
def test_check_version_mismatch(fail_state: State) -> None:
    assert [
        *_check_version(
            "1.2.3",
            "1.2.3",
            ("specific", {
                "literal": "1.2.2"
            }),
            fail_state,
        )
    ] == [
        Result(state=fail_state, summary="Version: 1.2.3 (expected 1.2.2)"),
    ]
Example #8
0
def test_check_version_at_least_daily_build_vs_release():
    assert [
        *_check_version(
            "1.2.3-2022.02.03",
            "site.version",
            ("at_least", {
                "release": "1.2.3"
            }),
            State.WARN,
        )
    ] == [
        Result(
            state=State.WARN,
            summary="Version: 1.2.3-2022.02.03 (expected at least 1.2.3)",
        )
    ]
Example #9
0
def test_check_version_at_least_daily_build():
    assert [
        *_check_version(
            "1.2.3-2021.02.03",
            "site.version",
            ("at_least", {
                "daily_build": "2022.03.04"
            }),
            State.WARN,
        )
    ] == [
        Result(
            state=State.WARN,
            summary="Version: 1.2.3-2021.02.03 (expected at least 2022.03.04)",
        )
    ]