import pytest
from src.models import FileItem

def test_file_item_fields():
 """Test that FileItem exists and has correct default values."""
 item = FileItem(path="src/models.py")
 assert item.path == "src/models.py"
 assert item.auto_aggregate is True
 assert item.force_full is False
 assert item.view_mode == "full"
 assert item.ast_mask == {}
 assert item.custom_slices == []
 assert item.injected_at is None

def test_file_item_to_dict():
 """Test that FileItem can be serialized to a dict."""
 item = FileItem(path="test.py", auto_aggregate=False, force_full=True, view_mode="summary")
 expected = {
  "path": "test.py",
  "auto_aggregate": False,
  "force_full": True,
  "view_mode": "summary",
  "ast_signatures": False,
  "ast_definitions": False,
  "ast_mask": {},
  "custom_slices": [],
  "injected_at": None
 }
 assert item.to_dict() == expected

def test_file_item_from_dict():
 """Test that FileItem can be deserialized from a dict."""
 data = {
  "path": "test.py",
  "auto_aggregate": False,
  "force_full": True,
  "view_mode": "summary",
  "injected_at": 123.456
 }
 item = FileItem.from_dict(data)
 assert item.path == "test.py"
 assert item.auto_aggregate is False
 assert item.force_full is True
 assert item.view_mode == "summary"
 assert item.injected_at == 123.456
 assert item.ast_mask == {}

def test_file_item_from_dict_defaults():
 """Test that FileItem.from_dict handles missing fields."""
 data = {"path": "test.py"}
 item = FileItem.from_dict(data)
 assert item.path == "test.py"
 assert item.auto_aggregate is True
 assert item.force_full is False
 assert item.view_mode == "full"
 assert item.ast_mask == {}
 assert item.custom_slices == []
 assert item.injected_at is None