feat(models): Add manual_block field and methods to Ticket
This commit is contained in:
@@ -74,11 +74,23 @@ class Ticket:
|
|||||||
blocked_reason: Optional[str] = None
|
blocked_reason: Optional[str] = None
|
||||||
step_mode: bool = False
|
step_mode: bool = False
|
||||||
retry_count: int = 0
|
retry_count: int = 0
|
||||||
|
manual_block: bool = False
|
||||||
|
|
||||||
def mark_blocked(self, reason: str) -> None:
|
def mark_blocked(self, reason: str) -> None:
|
||||||
self.status = "blocked"
|
self.status = "blocked"
|
||||||
self.blocked_reason = reason
|
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:
|
def mark_complete(self) -> None:
|
||||||
self.status = "completed"
|
self.status = "completed"
|
||||||
|
|
||||||
@@ -99,6 +111,7 @@ class Ticket:
|
|||||||
"blocked_reason": self.blocked_reason,
|
"blocked_reason": self.blocked_reason,
|
||||||
"step_mode": self.step_mode,
|
"step_mode": self.step_mode,
|
||||||
"retry_count": self.retry_count,
|
"retry_count": self.retry_count,
|
||||||
|
"manual_block": self.manual_block,
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -116,6 +129,7 @@ class Ticket:
|
|||||||
blocked_reason=data.get("blocked_reason"),
|
blocked_reason=data.get("blocked_reason"),
|
||||||
step_mode=data.get("step_mode", False),
|
step_mode=data.get("step_mode", False),
|
||||||
retry_count=data.get("retry_count", 0),
|
retry_count=data.get("retry_count", 0),
|
||||||
|
manual_block=data.get("manual_block", False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
23
tests/test_manual_block.py
Normal file
23
tests/test_manual_block.py
Normal file
@@ -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"
|
||||||
Reference in New Issue
Block a user