feat(mma): Implement Ticket and Track models
This commit is contained in:
22
models.py
Normal file
22
models.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Ticket:
|
||||||
|
"""
|
||||||
|
Represents a discrete unit of work within a track.
|
||||||
|
"""
|
||||||
|
id: str
|
||||||
|
description: str
|
||||||
|
status: str
|
||||||
|
assigned_to: str
|
||||||
|
depends_on: List[str] = field(default_factory=list)
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Track:
|
||||||
|
"""
|
||||||
|
Represents a collection of tickets that together form an architectural track or epic.
|
||||||
|
"""
|
||||||
|
id: str
|
||||||
|
description: str
|
||||||
|
tickets: List[Ticket] = field(default_factory=list)
|
||||||
69
tests/test_mma_models.py
Normal file
69
tests/test_mma_models.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import pytest
|
||||||
|
from models import Ticket, Track
|
||||||
|
|
||||||
|
def test_ticket_instantiation():
|
||||||
|
"""
|
||||||
|
Verifies that a Ticket can be instantiated with its required fields:
|
||||||
|
id, description, status, assigned_to.
|
||||||
|
"""
|
||||||
|
ticket_id = "T1"
|
||||||
|
description = "Implement surgical code changes"
|
||||||
|
status = "todo"
|
||||||
|
assigned_to = "tier3-worker"
|
||||||
|
|
||||||
|
ticket = Ticket(
|
||||||
|
id=ticket_id,
|
||||||
|
description=description,
|
||||||
|
status=status,
|
||||||
|
assigned_to=assigned_to
|
||||||
|
)
|
||||||
|
|
||||||
|
assert ticket.id == ticket_id
|
||||||
|
assert ticket.description == description
|
||||||
|
assert ticket.status == status
|
||||||
|
assert ticket.assigned_to == assigned_to
|
||||||
|
assert ticket.depends_on == []
|
||||||
|
|
||||||
|
def test_ticket_with_dependencies():
|
||||||
|
"""
|
||||||
|
Verifies that a Ticket can store dependencies.
|
||||||
|
"""
|
||||||
|
ticket = Ticket(
|
||||||
|
id="T2",
|
||||||
|
description="Write code",
|
||||||
|
status="todo",
|
||||||
|
assigned_to="worker-1",
|
||||||
|
depends_on=["T1"]
|
||||||
|
)
|
||||||
|
assert ticket.depends_on == ["T1"]
|
||||||
|
|
||||||
|
def test_track_instantiation():
|
||||||
|
"""
|
||||||
|
Verifies that a Track can be instantiated with its required fields:
|
||||||
|
id, description, and a list of Tickets.
|
||||||
|
"""
|
||||||
|
ticket1 = Ticket(id="T1", description="Task 1", status="todo", assigned_to="a")
|
||||||
|
ticket2 = Ticket(id="T2", description="Task 2", status="todo", assigned_to="b")
|
||||||
|
|
||||||
|
track_id = "TRACK-1"
|
||||||
|
track_desc = "Implement MMA Models"
|
||||||
|
tickets = [ticket1, ticket2]
|
||||||
|
|
||||||
|
track = Track(
|
||||||
|
id=track_id,
|
||||||
|
description=track_desc,
|
||||||
|
tickets=tickets
|
||||||
|
)
|
||||||
|
|
||||||
|
assert track.id == track_id
|
||||||
|
assert track.description == track_desc
|
||||||
|
assert len(track.tickets) == 2
|
||||||
|
assert track.tickets[0].id == "T1"
|
||||||
|
assert track.tickets[1].id == "T2"
|
||||||
|
|
||||||
|
def test_track_can_handle_empty_tickets():
|
||||||
|
"""
|
||||||
|
Verifies that a Track can be instantiated with an empty list of tickets.
|
||||||
|
"""
|
||||||
|
track = Track(id="TRACK-2", description="Empty Track", tickets=[])
|
||||||
|
assert track.tickets == []
|
||||||
Reference in New Issue
Block a user