amoghrajesh commented on code in PR #70298:
URL: https://github.com/apache/airflow/pull/70298#discussion_r4044091183
##########
dev/registry/tests/test_extract_parameters.py:
##########
@@ -266,12 +322,335 @@ def
test_manual_durable_marker_qualifies_without_mixin(self):
def test_subclass_not_redeclaring_marker_disqualifies(self):
assert is_durable_capable(ManuallyDurableSubclass,
FakeResumableJobMixin) is False
+ def test_subclass_with_no_execute_override_inherits_marker(self):
+ assert is_durable_capable(ManuallyDurableSubclassNoOverride,
FakeResumableJobMixin) is True
+
+ def test_subclass_delegating_via_super_execute_qualifies(self):
+ assert is_durable_capable(ManuallyDurableSubclassDelegating,
FakeResumableJobMixin) is True
+
+ def test_subclass_delegating_via_super_execute_multi_hop_qualifies(self):
+ assert is_durable_capable(ManuallyDurableSubclassDelegatingMultiHop,
FakeResumableJobMixin) is True
+
+ def test_multiple_inheritance_decorator_mixin_qualifies(self):
+ assert is_durable_capable(DecoratedDurableSubclass,
FakeResumableJobMixin) is True
+
+ def test_multiple_inheritance_no_own_execute_qualifies(self):
+ assert is_durable_capable(DecoratedDurableSubclassNoOwnExecute,
FakeResumableJobMixin) is True
+
+ def test_mixin_subclass_delegating_via_super_execute_qualifies(self):
+ class MixinSubclassDelegating(FullyImplementedResumableOperator):
+ def execute(self, context):
+ return super().execute(context)
+
+ assert is_durable_capable(MixinSubclassDelegating,
FakeResumableJobMixin) is True
+
+ def test_explicit_parent_class_delegation_qualifies(self):
+ assert is_durable_capable(ExplicitParentDelegatingSubclass,
FakeResumableJobMixin) is True
+
+ def
test_mixin_subclass_delegating_via_explicit_parent_call_qualifies(self):
+ class
MixinSubclassExplicitDelegating(FullyImplementedResumableOperator):
+ def execute(self, context):
+ return FullyImplementedResumableOperator.execute(self, context)
+
+ assert is_durable_capable(MixinSubclassExplicitDelegating,
FakeResumableJobMixin) is True
+
+ def test_declaring_class_with_leading_underscore_is_found(self):
+ """Python strips leading underscores from the class name when
mangling, so the
+ lookup must too, or a declaring class like `_FooOperator` is never
found."""
+
+ class _UnderscoreOperator:
+ __supports_durable_execution = True
+
+ def execute(self, context):
+ return None
+
+ assert is_durable_capable(_UnderscoreOperator, FakeResumableJobMixin)
is True
+
+ def
test_comment_mentioning_delegation_is_not_mistaken_for_delegation(self):
+ """A comment can say the opposite of what the code does; a raw-text
search must not
+ be fooled by it into reporting capable."""
+
+ class CommentedNonDelegatingSubclass(ManuallyDurableOperator):
+ def execute(self, context):
+ # overrides execute rather than calling super().execute(),
+ return None
+
+ assert is_durable_capable(CommentedNonDelegatingSubclass,
FakeResumableJobMixin) is False
+
+ def test_decoy_execute_call_does_not_shadow_real_delegation(self):
Review Comment:
Renamed the existing one to what it actually tests, which is the not a class
in the MRO skip. Added a second one that binds the ordering behaviour: the
decoy names a class that is in the MRO but owns no execute, with nothing after
it that does, so the hop resolves to no owner and the walk has to continue to
the real delegation below. Confirmed changing the loop to return on the first
resolved match turns exactly that test red.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]