Files
manual_slop/tests/test_file_item_model.py

45 lines
1.3 KiB
Python

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.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)
expected = {
"path": "test.py",
"auto_aggregate": False,
"force_full": True,
"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,
"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.injected_at == 123.456
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.injected_at is None