import pytest
from src.models import Ticket

def test_ticket_has_model_override_field():
 t = Ticket(id="T-001", description="Test")
 assert hasattr(t, 'model_override'), "Ticket must have model_override field"
 assert t.model_override is None, "model_override should default to None"

def test_model_override_serialization():
 t = Ticket(id="T-001", description="Test", model_override="gemini-3.1-pro-preview")
 d = t.to_dict()
 assert d.get('model_override') == "gemini-3.1-pro-preview", "to_dict should include model_override"

def test_model_override_deserialization():
 d = {"id": "T-001", "description": "Test", "model_override": "gemini-2.5-flash"}
 t = Ticket.from_dict(d)
 assert t.model_override == "gemini-2.5-flash", "from_dict should restore model_override"

def test_model_override_default_on_deserialize():
 d = {"id": "T-001", "description": "Test"}
 t = Ticket.from_dict(d)
 assert t.model_override is None, "Missing model_override should default to None"
