From 094a6c3c222bcf8d712220e25d36c37fd436abf4 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 7 Mar 2026 16:25:44 -0500 Subject: [PATCH] feat(models): Add manual_block field and methods to Ticket --- src/models.py | 14 ++++++++++++++ tests/test_manual_block.py | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/test_manual_block.py diff --git a/src/models.py b/src/models.py index 693e9d8..e87075f 100644 --- a/src/models.py +++ b/src/models.py @@ -74,11 +74,23 @@ class Ticket: blocked_reason: Optional[str] = None step_mode: bool = False retry_count: int = 0 + manual_block: bool = False def mark_blocked(self, reason: str) -> None: self.status = "blocked" self.blocked_reason = reason + def mark_manual_block(self, reason: str) -> None: + self.status = "blocked" + self.blocked_reason = f"[MANUAL] {reason}" + self.manual_block = True + + def clear_manual_block(self) -> None: + if self.manual_block: + self.status = "todo" + self.blocked_reason = None + self.manual_block = False + def mark_complete(self) -> None: self.status = "completed" @@ -99,6 +111,7 @@ class Ticket: "blocked_reason": self.blocked_reason, "step_mode": self.step_mode, "retry_count": self.retry_count, + "manual_block": self.manual_block, } @classmethod @@ -116,6 +129,7 @@ class Ticket: blocked_reason=data.get("blocked_reason"), step_mode=data.get("step_mode", False), retry_count=data.get("retry_count", 0), + manual_block=data.get("manual_block", False), ) diff --git a/tests/test_manual_block.py b/tests/test_manual_block.py new file mode 100644 index 0000000..fab8049 --- /dev/null +++ b/tests/test_manual_block.py @@ -0,0 +1,23 @@ +import pytest +from src.models import Ticket + +def test_ticket_has_manual_block_field(): + t = Ticket(id="T-001", description="Test") + assert hasattr(t, 'manual_block'), "Ticket must have manual_block field" + assert t.manual_block == False, "manual_block should default to False" + +def test_mark_manual_block_method(): + t = Ticket(id="T-001", description="Test") + t.mark_manual_block("Test reason") + assert t.status == "blocked", "Status should be blocked" + assert t.manual_block == True, "manual_block should be True" + assert "[MANUAL]" in t.blocked_reason, "blocked_reason should contain [MANUAL]" + +def test_clear_manual_block_method(): + t = Ticket(id="T-001", description="Test") + t.mark_manual_block("Test reason") + assert t.manual_block == True + t.clear_manual_block() + assert t.status == "todo", "Status should be restored to todo" + assert t.manual_block == False, "manual_block should be False" + assert t.blocked_reason is None, "blocked_reason should be cleared"