Tests: inc-site attribute extension construct path + memoized reference target#1468
Draft
rly wants to merge 1 commit into
Draft
Tests: inc-site attribute extension construct path + memoized reference target#1468rly wants to merge 1 commit into
rly wants to merge 1 commit into
Conversation
…d reference target Closes the gaps PR #283 (#283) flagged but never landed: round-trip construct coverage for inc-site added attributes (group + dataset) and a positive test that inc-site attributes are applied when the same dataset is also reachable through a typed reference dataset. Also uncomments TestBuildGroupRefinedAttr.test_build_refined_attr_wrong_type (the attribute counterpart of TestBuildDatasetRefinedDtype.test_build_refined_dtype_convert) and refactors the BuildGroupExtAttrsMixin / BuildDatasetExtAttrsMixin / BuildDatasetShapeMixin / TestBuildDatasetAddedAttrsWithRef setUps to use create_test_type_map. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1468 +/- ##
=======================================
Coverage 93.20% 93.20%
=======================================
Files 41 41
Lines 10176 10176
Branches 2103 2103
=======================================
Hits 9485 9485
Misses 415 415
Partials 276 276 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the test gaps PR #283 flagged but never landed:
TestBuildGroupAddedAttr.test_construct_added_attrandTestBuildDatasetAddedAttrs.test_construct_added_attrbuild a holder containing an extended Bar / BarData with an inc-siteext_attr, then construct from the resulting builder and assert the attribute round-trips. Required adding@ObjectMapper.constructor_arg('ext_attr')toExtBarMapper/ExtBarDataMapperso the inner mapper can recover an inc-site attribute that is not in its def-site spec.TestBuildDatasetAddedAttrsWithRef.test_build_added_attr_with_refbuilds a holder where the direct extendedbar_datafield and a sibling typed reference dataset (BarRefDataset) both point at the sameBarDatainstance, and asserts (a) the BarData builder carries the inc-siteext_attrand (b) the reference dataset'sReferenceBuilderresolves to that same memoized builder. Modern code only had the negative-caseTestBuildDatasetOfReferencesUnbuiltTarget.Also uncomments
TestBuildGroupRefinedAttr.test_build_refined_attr_wrong_type(the attribute counterpart ofTestBuildDatasetRefinedDtype.test_build_refined_dtype_convert— verifies build silently converts int -> int64 when the inc-site spec refines the dtype). The inline TODO is preserved noting that ideally aDtypeConversionWarningwould be emitted, mirroring the dataset case.The four touched mixin / test setUps were refactored to use
tests.unit.helpers.utils.create_test_type_mapinstead of hand-rolling SpecCatalog / SpecNamespace / NamespaceCatalog / TypeMap.Notes on design choices
PR #283 used a named-untyped dataset with
dtype=RefSpecdirectly holding a Container value. Modernconvert_dtyperequires aReferenceBuilderfor that path, so the with-ref test instead uses a typedDatasubclass (BarRefDataset) holding object references — the canonical "container of references" pattern (mirrorsBazintest_io_map_data.py).These tests do not move statement / branch coverage numbers (the underlying code paths are already exercised by other tests). They add behavioral guarantees at the inc-site-extension boundary that PR #283 was worried about.
Test plan
pytest tests/unit/build_tests/mapper_tests/test_build.py-> 20 passedpytest tests/-> 1891 passed, 22 skipped, 1 xfailed🤖 Generated with Claude Code