ci/lava: Fix LAVA job definition tests

Now that the LAVAJobSubmitter's `__post_init__` method is working for
unit tests, one of the job definitions parametrized tests started to
fail due to lack of LAVA proxy mocking.

This commit adds the missing pieces.

Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31882>
This commit is contained in:
Guilherme Gallo 2024-10-29 00:40:14 -03:00 committed by Marge Bot
parent bc86b73bbe
commit 2d5b574b8d

View file

@ -88,10 +88,19 @@ def mock_collabora_farm(clear_env_vars, monkeypatch):
@pytest.mark.parametrize("force_uart", [True, False], ids=["SSH", "UART"])
@pytest.mark.parametrize("mode", ["UBOOT", "FASTBOOT"])
@mock.patch("lava.lava_job_submitter.setup_lava_proxy")
def test_generate_lava_job_definition_sanity(
force_uart, mode, shell_file, mock_collabora_farm, monkeypatch
mock_lava_proxy,
force_uart,
mode,
shell_file,
mock_collabora_farm,
monkeypatch,
mock_proxy,
):
monkeypatch.setattr(lava.utils.lava_job_definition, "FORCE_UART", force_uart)
# Do not actually connect to the LAVA server
mock_lava_proxy.return_value = mock_proxy
init_script_content = f"echo test {mode}"
job_submitter = job_submitter_factory(mode, shell_file(init_script_content))
@ -175,8 +184,19 @@ def test_generate_lava_job_definition_sanity(
# use yaml files from tests/data/ to test the job definition generation
@pytest.mark.parametrize("force_uart", [False, True], ids=["SSH", "UART"])
@pytest.mark.parametrize("mode", ["UBOOT", "FASTBOOT"])
def test_lava_job_definition(mode, force_uart, shell_file, mock_collabora_farm, monkeypatch):
@mock.patch("lava.lava_job_submitter.setup_lava_proxy")
def test_lava_job_definition(
mock_lava_proxy,
mode,
force_uart,
shell_file,
mock_collabora_farm,
mock_proxy,
monkeypatch,
):
monkeypatch.setattr(lava.utils.lava_job_definition, "FORCE_UART", force_uart)
# Do not actually connect to the LAVA server
mock_lava_proxy.return_value = mock_proxy
yaml = YAML()
yaml.default_flow_style = False