feat(models): Add priority field to Ticket dataclass and update serialization
This commit is contained in:
37
tests/test_ticket_queue.py
Normal file
37
tests/test_ticket_queue.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
from src.models import Ticket
|
||||
|
||||
def test_ticket_priority_default():
|
||||
ticket = Ticket(id="T1", description="Test ticket")
|
||||
assert ticket.priority == "medium"
|
||||
|
||||
def test_ticket_priority_custom():
|
||||
ticket_high = Ticket(id="T2", description="High priority", priority="high")
|
||||
assert ticket_high.priority == "high"
|
||||
|
||||
ticket_low = Ticket(id="T3", description="Low priority", priority="low")
|
||||
assert ticket_low.priority == "low"
|
||||
|
||||
def test_ticket_to_dict_priority():
|
||||
ticket = Ticket(id="T4", description="To dict test", priority="high")
|
||||
d = ticket.to_dict()
|
||||
assert "priority" in d
|
||||
assert d["priority"] == "high"
|
||||
|
||||
def test_ticket_from_dict_priority():
|
||||
data = {
|
||||
"id": "T5",
|
||||
"description": "From dict test",
|
||||
"priority": "low",
|
||||
"status": "todo"
|
||||
}
|
||||
ticket = Ticket.from_dict(data)
|
||||
assert ticket.priority == "low"
|
||||
|
||||
def test_ticket_from_dict_default_priority():
|
||||
data = {
|
||||
"id": "T6",
|
||||
"description": "No priority in dict"
|
||||
}
|
||||
ticket = Ticket.from_dict(data)
|
||||
assert ticket.priority == "medium"
|
||||
Reference in New Issue
Block a user