fix issue label state transitions
This commit is contained in:
parent
fdb454414d
commit
3c6d41b49c
|
|
@ -68,8 +68,8 @@ class Gitea:
|
|||
if missing:
|
||||
raise LoopError(f"Missing repository labels: {', '.join(missing)}")
|
||||
self.request(
|
||||
"PATCH",
|
||||
f"/repos/{self.repo}/issues/{number}",
|
||||
"PUT",
|
||||
f"/repos/{self.repo}/issues/{number}/labels",
|
||||
{"labels": [label_map[name] for name in sorted(names)]},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,35 @@
|
|||
import unittest
|
||||
|
||||
from scripts.lab_loop import LoopError, issue_label_names, transition, validate_owner
|
||||
from scripts.lab_loop import Gitea, LoopError, issue_label_names, transition, validate_owner
|
||||
|
||||
|
||||
class RecordingGitea(Gitea):
|
||||
def __init__(self):
|
||||
super().__init__("https://example.invalid/api/v1", "owner/repo", "secret")
|
||||
self.calls = []
|
||||
|
||||
def labels(self):
|
||||
return {"agent:timmy": 1, "state:claimed": 2, "priority:P0": 3}
|
||||
|
||||
def request(self, method, path, payload=None):
|
||||
self.calls.append((method, path, payload))
|
||||
|
||||
|
||||
class LoopProtocolTests(unittest.TestCase):
|
||||
def test_set_labels_uses_gitea_replace_labels_endpoint(self):
|
||||
api = RecordingGitea()
|
||||
api.set_labels(7, {"agent:timmy", "state:claimed", "priority:P0"})
|
||||
self.assertEqual(
|
||||
api.calls,
|
||||
[
|
||||
(
|
||||
"PUT",
|
||||
"/repos/owner/repo/issues/7/labels",
|
||||
{"labels": [1, 3, 2]},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def test_transition_replaces_agent_and_state_but_preserves_kind_and_priority(self):
|
||||
labels = {"agent:timmy", "state:claimed", "priority:P1", "kind:build"}
|
||||
self.assertEqual(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user