refactor(ai_review): drop AI_REVIEW/AI_USAGE label plumbing
This commit is contained in:
@@ -663,35 +663,6 @@ def test_reference_non_url_renders_as_plain_text():
|
||||
assert "](CVE-" not in body
|
||||
|
||||
|
||||
def test_pr_has_label_reads_the_live_labels(monkeypatch):
|
||||
# The AI-USAGE opt-in is read at render time, not from the trigger
|
||||
# payload: labelling AI-REVIEW then AI-USAGE is two events, the review
|
||||
# claims on the first, and the second is dropped by the in-flight dedupe.
|
||||
seen = {}
|
||||
|
||||
def _get(api, repo, path, token, accept="application/json"):
|
||||
seen["path"] = path
|
||||
return 200, b'[{"name": "AI-REVIEW"}, {"name": "AI-USAGE"}]'
|
||||
|
||||
monkeypatch.setattr(ai_review, "gitea_get", _get)
|
||||
assert ai_review.pr_has_label("http://api", "o/r", "9", "t", "AI-USAGE") is True
|
||||
assert seen["path"] == "issues/9/labels"
|
||||
assert ai_review.pr_has_label("http://api", "o/r", "9", "t", "NOPE") is False
|
||||
|
||||
|
||||
def test_pr_has_label_survives_a_broken_api(monkeypatch):
|
||||
def _boom(*a, **k):
|
||||
raise RuntimeError("gitea down")
|
||||
monkeypatch.setattr(ai_review, "gitea_get", _boom)
|
||||
assert ai_review.pr_has_label("http://api", "o/r", "9", "t", "AI-USAGE") is False
|
||||
|
||||
monkeypatch.setattr(ai_review, "gitea_get", lambda *a, **k: (404, b"nope"))
|
||||
assert ai_review.pr_has_label("http://api", "o/r", "9", "t", "AI-USAGE") is False
|
||||
|
||||
monkeypatch.setattr(ai_review, "gitea_get", lambda *a, **k: (200, b'{"not": "a list"}'))
|
||||
assert ai_review.pr_has_label("http://api", "o/r", "9", "t", "AI-USAGE") is False
|
||||
|
||||
|
||||
def test_int_env_falls_back_on_garbage(monkeypatch, capsys):
|
||||
monkeypatch.setenv("PRAGENT_DIFF_CONTEXT", "two")
|
||||
assert ai_review._int_env("PRAGENT_DIFF_CONTEXT", 1) == 1
|
||||
|
||||
Reference in New Issue
Block a user