Skip to content

Commit

Permalink
envoy.ci.report(0.0.2): Minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Oct 10, 2024
1 parent 768d065 commit a0e0eb1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion envoy.ci.report/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2
5 changes: 4 additions & 1 deletion envoy.ci.report/envoy/ci/report/abstract/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ async def fetch_check(
event: str,
info: dict) -> tuple[str, str, dict] | None:
check_run = await self.repo.getitem(f"check-runs/{info['check-id']}")
if int(check_run["external_id"]) not in await self.workflows:
not_found = (
not check_run.get("external_id")
or int(check_run["external_id"]) not in await self.workflows)
if not_found:
return None
del info["action"]
info.pop("advice", None)
Expand Down
16 changes: 14 additions & 2 deletions envoy.ci.report/tests/test_abstract_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ async def test_runs_workflows_url(iters, filters):


@pytest.mark.parametrize("include_workflow", [True, False])
async def test_runs_fetch_check(patches, include_workflow):
@pytest.mark.parametrize("has_external_id", [True, False])
async def test_runs_fetch_check(patches, include_workflow, has_external_id):
repo = MagicMock()
repo.getitem = AsyncMock()
repo.getitem.return_value.get = MagicMock(
return_value=has_external_id)
runs = report.abstract.ACIRuns(repo)
patched = patches(
"int",
Expand All @@ -328,15 +331,24 @@ async def test_runs_fetch_check(patches, include_workflow):
assert (
await runs.fetch_check(commit, event, info)
== ((commit, event, info)
if include_workflow
if (has_external_id and include_workflow)
else None))

assert (
repo.getitem.call_args
== [(f"check-runs/{info.__getitem__.return_value}", ), {}])
assert (
repo.getitem.return_value.get.call_args
== [("external_id", ), {}])
assert (
info.__getitem__.call_args
== [("check-id", ), {}])
if not has_external_id:
assert not m_int.called
assert not repo.getitem.return_value.__getitem__.called
assert not info.pop.called
assert not info.__setitem__.called
return
assert (
m_int.call_args
== [(repo.getitem.return_value.__getitem__.return_value, ), {}])
Expand Down

0 comments on commit a0e0eb1

Please sign in to comment.