Massive Improvements & MVP Patches
This commit is contained in:
@@ -79,3 +79,57 @@ def test_webhook_accepts_review_and_queues(monkeypatch) -> None:
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "queued"
|
||||
assert posted_comments
|
||||
|
||||
|
||||
def test_webhook_logs_when_no_codex_review_command(monkeypatch) -> None:
|
||||
messages: list[str] = []
|
||||
|
||||
def _log_info(message: str, *args, **_kwargs) -> None:
|
||||
messages.append(message % args if args else message)
|
||||
|
||||
monkeypatch.setattr("gitea_codex_bot.main.logger.info", _log_info)
|
||||
client = TestClient(app)
|
||||
payload_obj = _payload("hello world", username="alice", comment_id=222)
|
||||
raw = json.dumps(payload_obj).encode()
|
||||
|
||||
response = client.post(
|
||||
"/webhook/gitea",
|
||||
content=raw,
|
||||
headers={
|
||||
"X-Gitea-Event": "issue_comment",
|
||||
"X-Gitea-Delivery": "d-3",
|
||||
"X-Gitea-Signature": _sign(raw),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["reason"] == "no codex command"
|
||||
assert any("Webhook ignored: no @codex review command" in item for item in messages)
|
||||
|
||||
|
||||
def test_webhook_logs_when_codex_command_is_not_review(monkeypatch) -> None:
|
||||
messages: list[str] = []
|
||||
|
||||
def _log_info(message: str, *args, **_kwargs) -> None:
|
||||
messages.append(message % args if args else message)
|
||||
|
||||
monkeypatch.setattr("gitea_codex_bot.main.logger.info", _log_info)
|
||||
client = TestClient(app)
|
||||
payload_obj = _payload("@codex explain", username="alice", comment_id=223)
|
||||
raw = json.dumps(payload_obj).encode()
|
||||
|
||||
response = client.post(
|
||||
"/webhook/gitea",
|
||||
content=raw,
|
||||
headers={
|
||||
"X-Gitea-Event": "issue_comment",
|
||||
"X-Gitea-Delivery": "d-4",
|
||||
"X-Gitea-Signature": _sign(raw),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "queued"
|
||||
assert any("Webhook without @codex review command" in item for item in messages)
|
||||
|
||||
Reference in New Issue
Block a user