Skip to content

Test fixtures build documents that declare a required file and bind none #293

Closed

Description

@stevevanhooser

What

VH-Lab/DID-python#86 closed the fail-open in check_files' step 3, which used to loop over the actual file_info entries and fall through to valid when a required name had none. Documents like that are now refused where they are created rather than accepted and failed on at read.

#292 fixed the half of this that was a product bug — element_timeseries.addepoch skipping the vhsb when an epoch had no samples — taking CI from 26 failed + 29 errors to 21 failed. This issue is the other half, which is entirely test-side: fixtures that construct a document declaring a required file and never bind one.

The 21

tests document unbound file
tests/test_session_database_rm.py (5) data/generic_file generic_file.ext
tests/matlab_tests/test_core.py, test_database.py, test_fun.py, test_session.py, test_validators.py demoNDI filename1.ext
tests/test_extract_doc_files_series.py demoNDI filename1.ext
tests/test_did_integration.py (1) — see below

Roughly twenty construction sites across a dozen files.

What the fix is, and what it is not

Attach a file at each site, or use a document class that declares none. Do not relax the schemas. A generic_file genuinely requires generic_file.ext; that is the same constraint VH-Lab/NDI-matlab#977 respected when makeSourceFile moved to fileReference rather than emitting a generic_file with nothing attached. The schema is describing reality in each case; the fixtures are the things that are wrong.

tests/matlab_tests/conftest.py::_add_doc_with_file already does it correctly — it writes a file and calls doc.add_file("filename1.ext", ...). Individual tests that build a demoNDI inline skip that step. That helper is the model to follow.

tests/test_did_integration.py::TestBundledDefinitions::test_definitions_validate_or_are_listed is different in kind: its allowlist records the error code each definition is expected to fail with, and DID now reports DID:Database:ValidationFiles where the list says ValidationFieldInteger / ValidationFieldDouble. That is an allowlist update, and worth reading rather than pattern-matching — the codes changing means the first thing that fails about those definitions changed.

Done when

main is green with did installed from main. Note that a local run needs both did and vhlab-toolbox-python reinstalled from main to match CI; a stale vhlab-toolbox-python makes vhsb_write raise zero-size array to reduction operation maximum on short arrays and hides the real failures behind noise.

Order

#292 is complete as scoped but cannot reach green alone, so it and this work land together — either this branches from claude/element-epoch-binary-always-bound, or #292 merges first with its 21 known reds and this follows immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions