DEVX-136: feat: add fix_pr_title module and update_pr API method
Post-merge / detect-and-configure (push) Successful in 12s
Post-merge / release-and-maintain (push) Successful in 1m0s

This commit was merged in pull request #203.
This commit is contained in:
2026-07-13 23:55:11 +00:00
parent 68f0872134
commit ddfbdec956
32 changed files with 2761 additions and 322 deletions
+32 -9
View File
@@ -152,7 +152,8 @@ class TestPrintLogs:
class TestCli:
def test_no_token_raises(self, monkeypatch: pytest.MonkeyPatch) -> None:
@patch("devx.tools.pr_status.subprocess.run")
def test_no_token_raises(self, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
for name in ("DEVELOPER_GITEA_API_TOKEN", "CI_GITEA_API_TOKEN", "CI_GITEA_TOKEN"):
monkeypatch.delenv(name, raising=False)
runner = CliRunner()
@@ -164,8 +165,9 @@ class TestCli:
assert result.exit_code != 0
assert "CI_GITEA_TOKEN" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.REPO_OWNER", "")
def test_no_owner_raises(self, monkeypatch: pytest.MonkeyPatch) -> None:
def test_no_owner_raises(self, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
runner = CliRunner()
result = runner.invoke(cli, ["--pr", "42"])
@@ -190,8 +192,11 @@ class TestCli:
assert result.exit_code != 0
assert "Fetching logs for PR #42" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_no_runs_found(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_no_runs_found(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -203,8 +208,11 @@ class TestCli:
assert result.exit_code != 0
assert "No workflow runs" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_no_jobs(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_no_jobs(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -219,8 +227,11 @@ class TestCli:
assert result.exit_code == 0
assert "No jobs" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_no_failed_jobs(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_no_failed_jobs(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -237,8 +248,11 @@ class TestCli:
assert result.exit_code == 0
assert "No failed jobs" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_failed_job_logs(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_failed_job_logs(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -266,8 +280,11 @@ class TestCli:
assert "FAILED step #3" in result.output
assert "error: test failed" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_specific_job(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_specific_job(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -286,8 +303,11 @@ class TestCli:
assert result.exit_code == 0
assert "lint output here" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_job_not_found(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_job_not_found(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")
@@ -304,8 +324,11 @@ class TestCli:
assert result.exit_code != 0
assert "No job matching" in result.output
@patch("devx.tools.pr_status.subprocess.run")
@patch("devx.tools.pr_logs.GiteaClient")
def test_no_sha_raises(self, mock_client_cls: MagicMock, monkeypatch: pytest.MonkeyPatch) -> None:
def test_no_sha_raises(
self, mock_client_cls: MagicMock, mock_subproc: MagicMock, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("CI_GITEA_TOKEN", "tok")
monkeypatch.setenv("DEVX_REPO_OWNER", "owner")
monkeypatch.setenv("DEVX_REPO_NAME", "repo")