test(pyamber): add unit tests for Operator base class#4735
Merged
Conversation
Closes apache#4733 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 @@
## main #4735 +/- ##
============================================
- Coverage 42.96% 42.52% -0.45%
+ Complexity 2035 2028 -7
============================================
Files 957 957
Lines 34077 34094 +17
Branches 3753 3753
============================================
- Hits 14642 14499 -143
- Misses 18659 18816 +157
- Partials 776 779 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
aglinxinyuan
approved these changes
May 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new pytest spec file to exercise the Operator base class behaviors in core/models/operator.py, improving unit-level confidence around template decoding, source-ness flags, default lifecycle hooks, and batch-size validation (per #4733).
Changes:
- Add tests for
Operator.PythonTemplateDecoder(stdlib + injectable decoder, caching + eviction). - Add tests for
Operator.is_sourcegetter/setter and document the currentSourceOperatorname-mangling bug. - Add tests for
Operatordefault no-op methods andBatchOperator._validate_batch_size.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…erage - Replace the "is_source=False as contract" pin with two tests: one that asserts the underlying name-mangled attribute divergence, and one strict xfail that asserts the *intended* contract (`is_source is True` for SourceOperator subclasses), so a future bugfix flips xfail to XPASS instead of looking like a regression. - Add TestTableOperator covering process_tuple buffering, on_finish building a Table from buffered tuples and routing it to process_table, the empty-buffer path, and per-port buffer isolation.
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.
What changes were proposed in this PR?
Adds pytest coverage for
amber/src/main/python/core/models/operator.py. TheOperatorabstract base class had no dedicated spec.Any related issues, documentation, discussions?
Closes #4733.
Bug pinned in the spec with an explanatory comment (filed separately as a Bug issue):
SourceOperatordeclares__internal_is_source = Trueat class level, but Python name-mangles that into_SourceOperator__internal_is_sourcewhileOperator.is_sourcereadsself._Operator__internal_is_source. The two are different attributes, so a freshSourceOperatorsubclass instance reportsis_source=FalseuntilExecutorManager.initialize_executorinvokes the explicit setter — making the class-level declaration effectively dead code.How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-7)