From 66f649ea3f15fe0c89138ea2e5a64fe38593e4ea Mon Sep 17 00:00:00 2001 From: sonhmai <14060682+sonhmai@users.noreply.github.com> Date: Fri, 21 Aug 2026 15:02:36 +0700 Subject: [PATCH] test(types): trim FileStat split test to the enforced invariant Keep only the two tests that guard real logic: the validator rejecting content on a non-FILE kind, and type being required. Drop the change-detector tests that restated the enum definition and the ones that only exercised pydantic field storage. --- python/tests/test_filestat_split.py | 52 ++++------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/python/tests/test_filestat_split.py b/python/tests/test_filestat_split.py index 1f0c7be84..653f38f80 100644 --- a/python/tests/test_filestat_split.py +++ b/python/tests/test_filestat_split.py @@ -3,60 +3,20 @@ from pydantic import ValidationError from mirage.types import ContentType, FileStat, FileType - -def test_file_carries_content(): - s = FileStat(name="a.txt", type=FileType.FILE, content=ContentType.TEXT) - assert s.type is FileType.FILE - assert s.content is ContentType.TEXT - - -def test_file_content_may_be_unknown(): - s = FileStat(name="a", type=FileType.FILE) - assert s.content is None - - -def test_directory_has_no_content(): - s = FileStat(name="d", type=FileType.DIRECTORY) - assert s.content is None - - -def test_symlink_has_no_content(): - s = FileStat(name="l", type=FileType.SYMLINK) - assert s.content is None - - _NON_FILE = [k for k in FileType if k is not FileType.FILE] @pytest.mark.parametrize("kind", _NON_FILE) -def test_content_on_non_file_is_rejected(kind): +def test_content_is_rejected_on_a_non_file_kind(kind): + # The one invariant the model enforces: content is a regular file's + # rendering hint, so a directory, symlink or device may not carry + # one. A FILE, by contrast, may carry content or leave it None. with pytest.raises(ValidationError): FileStat(name="x", type=kind, content=ContentType.JSON) -@pytest.mark.parametrize("kind", _NON_FILE) -def test_non_file_kinds_construct_without_content(kind): - # every declared kind is constructible (the not-yet-emitted device - # kinds included), carrying no content. - assert FileStat(name="x", type=kind).content is None - - -def test_full_posix_set_is_present(): - assert {k.name - for k in FileType} == { - "DIRECTORY", "FILE", "SYMLINK", "CHAR_DEVICE", "BLOCK_DEVICE", - "FIFO", "SOCKET" - } - - def test_type_is_required(): + # No default on type: a construction that forgets the node kind fails + # loud rather than silently defaulting to a regular file. with pytest.raises(ValidationError): FileStat(name="x") - - -def test_enums_are_disjoint(): - # node kinds live only on FileType; content shapes only on ContentType - assert not hasattr(ContentType, "DIRECTORY") - assert not hasattr(ContentType, "SYMLINK") - assert not hasattr(FileType, "JSON") - assert not hasattr(FileType, "TEXT")