amoghrajesh commented on PR #46613:
URL: https://github.com/apache/airflow/pull/46613#issuecomment-2647691470
Should something like this pass:
```
@pytest.mark.usefixtures("clear_all_logger_handlers")
def
test_extra_operator_links_logs_error_for_non_registered_extra_links(self):
"""
Assert OperatorLinks not registered via Plugins and if it is not an
inbuilt Operator Link,
it can still deserialize the DAG (does not error) but just logs an
error.
We test NOT using caplog as this is flaky, we check that the task
after deserialize
is missing the extra links.
"""
class TaskStateLink(BaseOperatorLink):
"""OperatorLink not registered via Plugins nor a built-in
OperatorLink"""
name = "My Link"
def get_link(self, operator, *, ti_key):
return "https://www.google.com"
class MyOperator(BaseOperator):
"""Just a EmptyOperator using above defined Extra Operator
Link"""
operator_extra_links = [TaskStateLink()]
def execute(self, context: Context):
pass
with DAG(dag_id="simple_dag", schedule=None,
start_date=datetime(2019, 8, 1)) as dag:
MyOperator(task_id="blah")
serialized_dag = SerializedDAG.to_dict(dag)
sdag = SerializedDAG.from_dict(serialized_dag)
assert sdag.task_dict["blah"].operator_extra_links == []
```
I do not really understand what:
```
Assert OperatorLinks not registered via Plugins and if it is not an
inbuilt Operator Link,
it can still deserialize the DAG (does not error) but just logs an
error.
We test NOT using caplog as this is flaky, we check that the task
after deserialize
is missing the extra links.
```
means.
--
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]