test(kc): test fixtures and automated round-trip tests for .kc file handling #46
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Create
.kctest fixtures and automated tests that verify the full document lifecycle: open, parsesilo/entries, create tree objects, edit metadata, save, reopen, and confirm round-trip integrity. Currently there are zero tests and zero.kcfixtures in the repository.Background
The
.kcfile handling system spans multiple components:kc_format.py— ZIP round-trip preservationsilo_tree.py— tree object creation fromsilo/entriessilo_objects.py— transient document objectssilo_document.py— document observer lifecycle hookskindred_document.py—silo/parsing and serializationsilo_viewers.py— viewer widgets (dirty tracking, save-back)None of these have tests. The
Prop_Transientflag behavior, observer registration ordering, and ZIP manipulation all have edge cases that need automated coverage.Scope
Test fixtures
Create minimal
.kcZIP files in a fixtures directory for test use:minimal.kcDocument.xml, emptyGuiDocument.xml) +silo/manifest.jsononlyfull.kcsilo/entry types: manifest, metadata, history, approvals, dependencies, one job YAML, one macro .pyno-silo.fcstd.fcstdwith nosilo/directory (regression: must not create Silo tree)stale-stubs.kc.kcwith Silo object stubs inDocument.xmlfrom a previous save (tests cleanup)empty-groups.kc.kcwith emptysilo/jobs/andsilo/macros/directories (tests conditional node creation — no empty groups)Fixture location:
tests/fixtures/orsrc/Mod/Create/tests/fixtures/Unit tests
kc_format.pytests.kc, verifysilo/entries are preservedsilo/manifest.json, verify it is createdmodified_atupdate: save twice, verify timestamp changespre_reinjectcallback: register callback, verify it receives and can modify cache dict.kcfiles: save a.fcstd, verify nosilo/entries are injectedsilo_tree.pytestsfull.kc, verify all expected tree nodes are createdminimal.kc, verify only Silo > Manifest existsempty-groups.kc, verify no Jobs/Macros groups createdstale-stubs.kc, verify old stubs are removed before new tree is created.fcstdno-op: parseno-silo.fcstd, verify no Silo tree objects createdsilo_objects.pytestsSiloViewerObject, verify all properties haveProp_Transientflag__getstate__returnsNoneRawContentsilo_document.pytestsslotCreatedDocumentfires and triggers tree creation for.kc.fcstd: verifyslotCreatedDocumentdoes not trigger tree creationslotDeletedDocumentkindred_document.pytestsfull.kc, verify eachsilo/entry is correctly parsedRawContent, save, reopen, verify changes persisted.fcstdto.kc, verifysilo/manifest.jsonis created with UUIDIntegration tests (require FreeCAD runtime)
full.kc→ verify tree → double-click Manifest → verify viewer opens → edit metadata → save → reopen → verify edits persisted.kc, Save As.fcstd, verify nosilo/directory in result.kcfixture in FreeCAD without Create module, verify no errorsTechnical notes
unittest-based testing viafreecad.appmodule. Tests can be run headless withfreecadcmd -t TestModule.freecad.gui(needs display orxvfb). Keep these separate from headless tests.zipfilemodule to create fixtures programmatically in test setup, or check in pre-built.kcfiles.Prop_Transientverification: The C++ source confirms flag value2works for dynamic properties (PropertyContainer.cpp:211), but this should be explicitly tested since no existing Python code in this codebase uses it.Acceptance criteria
.kctest fixtures exist covering the cases abovekc_format.pyround-trip tests passsilo_tree.pyconditional creation tests passsilo_objects.pytransient property tests passProp_Transientflag is verified to exclude property content fromDocument.xmlfreecadcmdin CIDependencies
silo_objects.py,silo_tree.py,silo_document.pykindred_document.pytestsReferences
docs/KC_SPECIFICATION.md§6 (acceptance criteria per layer)docs/SILO_VIEWPORT_PLAN.md(Risks section —Prop_Transientverification)src/Mod/Test/