Skip to content

Commit 3a2b8a9

Browse files
committed
misc(tests): Fixing broken test; Improving report
1 parent 6a95f9f commit 3a2b8a9

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: |
2525
set -o pipefail
2626
mkdir reports
27-
pytest --junit-xml=reports/pytest.xml --cov --cov-report=term-missing:skip-covered | tee reports/coverage.txt
27+
pytest --junit-xml=reports/pytest.xml --cov --cov-report=term-missing | tee reports/coverage.txt
2828
artifact: pytest-results
2929
artifact_path: reports/
3030
secrets: inherit

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ quote-style = "double"
3636
indent-style = "space"
3737
skip-magic-trailing-comma = false
3838
line-ending = "auto"
39+
40+
[tool.coverage.report]
41+
omit = [
42+
"tests/*",
43+
]

tests/test_obs_install.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from functools import partial
2+
from itertools import count
23
from pathlib import Path
34
from unittest.mock import call, patch
45

@@ -12,25 +13,27 @@ def obs_install_action(action_cls, args_mock, tmp_data_folder, start_cmd_mock):
1213
action = ObsInstallAction()
1314
args_mock.prod = "obs"
1415
args_mock.action = "install"
15-
with patch.object(action, "execute", new=partial(action.execute, args_mock)):
16+
with (
17+
patch.object(action, "execute", new=partial(action.execute, args_mock)),
18+
patch("platform.system", return_value="Linux"),
19+
):
1620
yield action
1721

1822

1923
@pytest.mark.integration
2024
def test_obs_install(obs_install_action, start_cmd_mock, tmp_data_folder, stdout_mock):
21-
stdout_mock.side_effect = (
22-
[b"{}"],
23-
[],
24-
[],
25-
[],
26-
[],
27-
[],
28-
[],
29-
[b'{"service_account_key": "demo-account-key", "project_id": "test-project-id"}'],
30-
[],
31-
[],
32-
)
25+
def _stdout_side_effect():
26+
for idx in count():
27+
if idx == 0:
28+
yield [b"{}"]
29+
elif idx == 7:
30+
yield [b'[{"Name": "observability-ui", "URLs": ["http://localhost:8501"]}]']
31+
elif idx == 8:
32+
yield [b'{"service_account_key": "demo-account-key", "project_id": "test-project-id"}']
33+
else:
34+
yield []
3335

36+
stdout_mock.side_effect = iter(_stdout_side_effect())
3437
obs_install_action.execute()
3538

3639
def_call = partial(call, raise_on_non_zero=True, env=None)

0 commit comments

Comments
 (0)