Skip to content

test(fhir): add regression tests for empty and dangling-reference Bundle edges#556

Merged
maziyarpanahi merged 2 commits into
maziyarpanahi:masterfrom
axelray-dev:fix/547-bundle-edge-tests
Jun 22, 2026
Merged

test(fhir): add regression tests for empty and dangling-reference Bundle edges#556
maziyarpanahi merged 2 commits into
maziyarpanahi:masterfrom
axelray-dev:fix/547-bundle-edge-tests

Conversation

@axelray-dev

Copy link
Copy Markdown
Contributor

Closes #547.

Lock in two behaviors of to_bundle() that were correctly implemented but not explicitly tested:

  • Empty input: returns a well-formed Bundle with empty entry list for transaction, collection, and batch bundle types.
  • Dangling references: references to resources absent from the Bundle are preserved verbatim (not rewritten). Tests cover single, mixed internal/external, and multiple dangling references on one resource.

Test-only change. No source code modifications. All 18 tests pass (6 new + 12 existing).

pytest tests/unit/clinical/test_fhir_bundle_edge_cases.py -v
pytest tests/unit/clinical/test_fhir_bundle.py -v

…dle edges

Lock in two behaviors of to_bundle() that were correctly implemented
but not explicitly tested:

- Empty input returns a well-formed Bundle with empty entry list
  for transaction, collection, and batch bundle types.
- References to resources absent from the Bundle are preserved
  verbatim (not rewritten). Tests cover single, mixed internal/
  external, and multiple dangling references on one resource.

Closes maziyarpanahi#547.

Signed-off-by: axelray-dev <110029405+axelray-dev@users.noreply.github.com>
@axelray-dev axelray-dev marked this pull request as ready for review June 21, 2026 18:07
@maziyarpanahi maziyarpanahi added good first issue Good for newcomers help wanted Extra attention is needed improvement Hardening / refactor of existing code P3 Strategic roadmap-v2 OpenMed V2 roadmap backlog labels Jun 22, 2026

@maziyarpanahi maziyarpanahi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you @axelray-dev. I reviewed this against #547 / OM-362 and added one small maintainer follow-up commit: test: format FHIR bundle edge cases.

What I changed:

  • removed an unused import in the new edge-case test file;
  • applied the repository Ruff formatter to wrap the long dangling-reference assertion.

The test coverage itself matches the issue: empty resource lists produce well-formed empty Bundles for the requested bundle types, dangling references are preserved verbatim, and mixed internal/dangling references keep the existing rewrite behavior for resources present in the Bundle.

Verification on the current PR checkout:

  • PYTHONPATH=/private/tmp/openmed-pr-556 /Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py -q -> 18 passed
  • /Users/maziyar/Developer/openmed/.venv/bin/ruff check tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py -> passed
  • /Users/maziyar/Developer/openmed/.venv/bin/ruff format --check tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py -> passed

I also copied the labels from #547 onto the PR. The branch is mergeable with no conflicts; GitHub has not attached hosted checks to the new head commit yet, so I verified the touched behavior locally.

@maziyarpanahi maziyarpanahi merged commit 2763a5a into maziyarpanahi:master Jun 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers help wanted Extra attention is needed improvement Hardening / refactor of existing code P3 Strategic roadmap-v2 OpenMed V2 roadmap backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle empty and reference-only inputs in the FHIR Bundle assembler

2 participants