Skip to content

docs: explain model fixture and snapshot workflow - #1031

Open
CAOShurong wants to merge 2 commits into
CycloneDX:mainfrom
CAOShurong:codex/document-model-snapshots
Open

docs: explain model fixture and snapshot workflow#1031
CAOShurong wants to merge 2 commits into
CycloneDX:mainfrom
CAOShurong:codex/document-model-snapshots

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Description

Document the shared BOM model fixture workflow in tests/_data/snapshots/README.md:

  • how get_bom_* factories are discovered and named;
  • how valid and intentionally invalid fixtures are classified;
  • when to register an intentionally incomplete dependency graph;
  • how to regenerate, review, and verify snapshots safely.

The existing README only documented the recreation command. This fills the documentation gap identified by the maintainer in #914 without changing test behavior.

Resolves or fixes issue: #1030

Validation

  • python -m unittest tests.test_output_json tests.test_output_xml tests.test_deserialize_json tests.test_deserialize_xml — 750 tests passed.
  • python -m unittest discover -t . -s tests — 6,962 tests passed.
  • git diff --check — passed.

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: OpenAI Codex
    • LLMs and versions: GPT-5
    • Prompts: Audit maintainer-requested CycloneDX contribution paths, verify repository rules and duplicates, document the existing tests/_data/models.py fixture and snapshot workflow, and run focused and complete regression tests.

Affirmation

Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong
CAOShurong requested a review from a team as a code owner August 12, 2026 18:18
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jkowalleck jkowalleck added documentation Improvements or additions to documentation CT Continuous Testing labels Aug 13, 2026

@jkowalleck jkowalleck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort.
more docs -> more good!

Comment thread tests/_data/snapshots/README.md Outdated

The files will be written as is, which might not be human-readable. feel free to reformat the files manually.
Only commit snapshots that belong to the model change. Since snapshots are
compared byte-for-byte, do not reformat them manually.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where comes this "compared byte-for-byte" from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — that wording was imprecise. SnapshotMixin.assertEqualSnapshot() reads fixtures in text mode and calls self.assertEqual(actual, self.readSnapshot(snapshot_name)), so this is exact string equality after text decoding/newline handling, not a raw byte comparison. I updated the README in 698c855. I also reran the focused serialization/deserialization snapshot tests (750 tests) and the full suite (6,962 tests) in UTF-8 mode; both pass.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right.
This means, this part of the docs are wrong, and require changing:

The files will be written as is, which might not be human-readable. feel free to reformat the files manually.

Describe the exact string comparison used by SnapshotMixin without implying a raw byte comparison.

Assisted-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CT Continuous Testing documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants