Skip to content

Commit 419fb31

Browse files
committed
Fix tests
1 parent 60b1c0c commit 419fb31

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

scripts/src/scverse_template_scripts/cruft_prs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str) -> None:
242242
if old_pr := next((p for p in origin.get_pulls("open") if pr.matches_prefix(p)), None):
243243
log.info(f"Closing old PR #{old_pr.number} with branch name `{old_pr.head.ref}`.")
244244
old_pr.edit(state="closed")
245-
origin.create_pull(pr.title, pr.body, origin.default_branch, pr.namespaced_head)
245+
new_pr = origin.create_pull(pr.title, pr.body, origin.default_branch, pr.namespaced_head)
246+
log.info(f"Created PR #{new_pr.number} with branch name `{new_pr.head.ref}`.")
246247

247248

248249
def setup() -> None:

scripts/tests/test_cruft.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from dataclasses import dataclass
3+
from pathlib import Path
34
from typing import cast
45

56
import pytest
@@ -50,11 +51,12 @@ def pr(con) -> PR:
5051

5152
def test_cruft_update(con, repo, tmp_path, pr, git_repo: GitRepo, monkeypatch: pytest.MonkeyPatch):
5253
old_active_branch_name = git_repo.api.active_branch.name
53-
monkeypatch.setattr(
54-
"scverse_template_scripts.cruft_prs.run_cruft",
55-
lambda p, _, __: (p / "b").write_text("b modified"),
56-
)
57-
changed = cruft_update(con, "main", repo, repo, tmp_path, pr)
54+
55+
def _mock_run_cruft(cwd: Path, *, tag_name, log_name):
56+
(cwd / "b").write_text("b modified")
57+
58+
monkeypatch.setattr("scverse_template_scripts.cruft_prs.run_cruft", _mock_run_cruft)
59+
changed = cruft_update(con, pr, tag_name="main", repo=repo, origin=repo, path=tmp_path)
5860
assert changed # TODO: add test for short circuit
5961
main_branch = git_repo.api.active_branch
6062
assert main_branch.name == old_active_branch_name, "Shouldn’t change active branch"

0 commit comments

Comments
 (0)