Type annotations in tests

This commit is contained in:
Stéphane Bidoul 2021-11-14 10:29:07 +01:00
parent 87a021137b
commit 62c6b4caa2
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
4 changed files with 12 additions and 12 deletions

View file

@ -4,20 +4,20 @@ from runboat.build_images import get_build_image, get_main_branch, is_branch_sup
from runboat.exceptions import BranchNotSupported
def test_get_main_branch():
def test_get_main_branch() -> None:
assert get_main_branch("15.0") == "15.0"
assert get_main_branch("15.0-ocabot-merge") == "15.0"
with pytest.raises(BranchNotSupported):
get_main_branch("8.0")
def test_is_branch_supported():
def test_is_branch_supported() -> None:
assert is_branch_supported("15.0")
assert is_branch_supported("15.0-ocabot-merge")
assert not is_branch_supported("8.0")
def test_get_build_image():
def test_get_build_image() -> None:
assert get_build_image("15.0") == "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"
assert get_build_image("15.0-zzz") == "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"
with pytest.raises(BranchNotSupported):

View file

@ -29,14 +29,14 @@ def _make_build(
)
def test_add():
def test_add() -> None:
db = BuildsDb()
assert db.add(_make_build()) # new
assert not db.add(_make_build()) # no change
assert db.add(_make_build(status=BuildStatus.failed))
def test_remove():
def test_remove() -> None:
db = BuildsDb()
assert not db.remove("not-a-build")
build = _make_build()
@ -44,7 +44,7 @@ def test_remove():
assert db.remove(build.name)
def test_get_for_commit():
def test_get_for_commit() -> None:
db = BuildsDb()
build = _make_build()
db.add(build)
@ -62,7 +62,7 @@ def test_get_for_commit():
)
def test_search():
def test_search() -> None:
db = BuildsDb()
db.add(build1 := _make_build(name="b1", repo="oca/repo1"))
db.add(_make_build(name="b2", repo="oca/repo2"))
@ -70,7 +70,7 @@ def test_search():
assert db.search("oca/repo1") == [build1]
def test_count_by_status():
def test_count_by_status() -> None:
db = BuildsDb()
db.add(_make_build(name="b1", status=BuildStatus.started))
db.add(_make_build(name="b2", status=BuildStatus.stopped))
@ -79,7 +79,7 @@ def test_count_by_status():
assert db.count_by_status(BuildStatus.failed) == 0
def test_count_by_init_status():
def test_count_by_init_status() -> None:
db = BuildsDb()
db.add(_make_build(name="b1", init_status=BuildInitStatus.started))
db.add(_make_build(name="b2", init_status=BuildInitStatus.todo))
@ -88,7 +88,7 @@ def test_count_by_init_status():
assert db.count_by_init_status(BuildInitStatus.failed) == 0
def test_count_all():
def test_count_all() -> None:
db = BuildsDb()
assert db.count_all() == 0
db.add(_make_build(name="b1"))

View file

@ -10,5 +10,5 @@ from runboat.k8s import _split_image_name_tag
("postgres:12", ("postgres", "12")),
],
)
def test_split_image_name_tag(image, expected):
def test_split_image_name_tag(image: str, expected: tuple[str, str]) -> None:
assert _split_image_name_tag(image) == expected

View file

@ -65,7 +65,7 @@ patches:
"""
def test_render_kubefiles():
def test_render_kubefiles() -> None:
deployment_vars = make_deployment_vars(
mode=DeploymentMode.deployment,
build_name="build-name",