From 7b7dede218377970e1b9b2b96bb6b5753b5cf967 Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:30:43 -0800 Subject: [PATCH] try to satisfy codecov --- tests/test_main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 009f788..effc35d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -55,8 +55,8 @@ class MockCompletedProcess: returncode: int -@pytest.fixture -def subprocess_run_side_effect(): +@pytest.fixture(params=[True, False], ids=["has_job_id", "no_job_id"]) +def subprocess_run_side_effect(request): def _get_mock_completed_proc(cmd: list[str], *args, **kwargs): # `subprocess.run` is called a few ways, so use a side effect function # to vary the output depending on what arguments it was called with. @@ -68,8 +68,11 @@ def _get_mock_completed_proc(cmd: list[str], *args, **kwargs): returncode=returncode, ) elif "bake" in " ".join(cmd): + # not all bakery types have a job_id, represent that here + has_job_id = request.param + stdout = b'{"job_id": "foo", "job_name": "bar"}' if has_job_id else b'{}' return MockCompletedProcess( - stdout=b'{"job_id": "foo", "job_name": "bar"}', + stdout=stdout, stderr=b"", returncode=0, )