Public Access
DEVX-136: feat: add fix_pr_title module and update_pr API method
This commit was merged in pull request #203.
This commit is contained in:
@@ -255,7 +255,17 @@ class TestCommitAndPush:
|
||||
|
||||
|
||||
class TestMain:
|
||||
def test_no_token_raises(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
@patch("devx.ci.sync_wiki.commit_and_push")
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||
def test_no_token_raises(
|
||||
self,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
mock_commit: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
for name in ("CI_GITEA_API_TOKEN", "CI_GITEA_TOKEN"):
|
||||
monkeypatch.delenv(name, raising=False)
|
||||
runner = CliRunner()
|
||||
@@ -263,7 +273,17 @@ class TestMain:
|
||||
assert result.exit_code != 0
|
||||
assert "CI_GITEA_TOKEN" in result.output
|
||||
|
||||
def test_no_mapping_raises(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
@patch("devx.ci.sync_wiki.commit_and_push")
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||
def test_no_mapping_raises(
|
||||
self,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
mock_commit: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.setenv("CI_GITEA_TOKEN", "fake")
|
||||
monkeypatch.setattr("devx.ci.sync_wiki.MAPPING_FILE", tmp_path / "nonexistent.json")
|
||||
runner = CliRunner()
|
||||
@@ -271,6 +291,7 @@ class TestMain:
|
||||
assert result.exit_code != 0
|
||||
assert "mapping.json" in result.output
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||
@@ -279,6 +300,7 @@ class TestMain:
|
||||
mock_sync: MagicMock,
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -296,6 +318,7 @@ class TestMain:
|
||||
assert "dry-run" in result.output
|
||||
mock_push.assert_not_called()
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(2, 0))
|
||||
@@ -304,6 +327,7 @@ class TestMain:
|
||||
mock_sync: MagicMock,
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -348,6 +372,7 @@ class TestMain:
|
||||
assert result.exit_code == 0
|
||||
mock_init.assert_called_once()
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.time.sleep")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@@ -358,6 +383,7 @@ class TestMain:
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_sleep: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -383,6 +409,7 @@ class TestMain:
|
||||
assert result.exit_code == 0
|
||||
assert "Verification" in result.output
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=False)
|
||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||
@@ -391,6 +418,7 @@ class TestMain:
|
||||
mock_sync: MagicMock,
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -407,6 +435,7 @@ class TestMain:
|
||||
assert result.exit_code == 0
|
||||
assert "No push needed" in result.output
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.time.sleep")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki", side_effect=[True, False])
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@@ -417,6 +446,7 @@ class TestMain:
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_sleep: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -433,6 +463,7 @@ class TestMain:
|
||||
assert result.exit_code != 0
|
||||
assert "could not clone" in result.output
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.time.sleep")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki")
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@@ -443,6 +474,7 @@ class TestMain:
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_sleep: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -467,6 +499,7 @@ class TestMain:
|
||||
assert result.exit_code != 0
|
||||
assert "page(s) missing" in result.output
|
||||
|
||||
@patch("devx.ci.sync_wiki.init_wiki")
|
||||
@patch("devx.ci.sync_wiki.clone_wiki", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.commit_and_push", return_value=True)
|
||||
@patch("devx.ci.sync_wiki.sync_files", return_value=(1, 0))
|
||||
@@ -475,6 +508,7 @@ class TestMain:
|
||||
mock_sync: MagicMock,
|
||||
mock_push: MagicMock,
|
||||
mock_clone: MagicMock,
|
||||
mock_init: MagicMock,
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user