kaxil commented on a change in pull request #6715: [AIRFLOW-5945] Make inbuilt 
OperatorLinks work when using Serialization
URL: https://github.com/apache/airflow/pull/6715#discussion_r353696421
 
 

 ##########
 File path: tests/serialization/test_dag_serialization.py
 ##########
 @@ -381,6 +362,49 @@ def test_roundtrip_relativedelta(self, val, expected):
         round_tripped = SerializedDAG._deserialize(serialized)
         self.assertEqual(val, round_tripped)
 
+    def test_extra_serialized_field_and_operator_links(self):
+        """
+        Assert extra field exists & OperatorLinks defined in Plugins and 
inbuilt Operator Links.
+
+        This tests also depends on GoogleLink() registered as a plugin
+        in tests/plugins/test_plugin.py
+
+        The function tests that if extra operator links are registered in 
plugin
+        in ``operator_extra_links`` and the same is also defined in
+        the Operator in ``BaseOperator.operator_extra_links``, it has the 
correct
+        extra link.
+        """
+        test_date = datetime(2019, 8, 1)
+        dag = DAG(dag_id='simple_dag', start_date=test_date)
+        CustomBaseOperator(task_id='simple_task', dag=dag, bash_command="true")
+
+        serialized_dag = SerializedDAG.to_dict(dag)
+        self.assertIn("bash_command", serialized_dag["dag"]["tasks"][0])
+
+        dag = SerializedDAG.from_dict(serialized_dag)
+        simple_task = dag.task_dict["simple_task"]
+        self.assertEqual(getattr(simple_task, "bash_command"), "true")
+
+        #########################################################
+        # Verify Operator Links work with Serialized Operator
+        #########################################################
+        # Check Serialized version of operator link only contains the inbuilt 
Op Link
+        self.assertEqual(
+            serialized_dag["dag"]["tasks"][0]["_operator_links_sources"],
+            [{'airflow.utils.tests.CustomBaseOpLink': {}}]
 
 Review comment:
   Yes like:
   
   
https://github.com/apache/airflow/pull/6715/files#diff-5a167b261e34f0a91d371b5429ace188R492-R499
 :
   
   ```
           # Check Serialized version of operator link
           self.assertEqual(
               serialized_dag["dag"]["tasks"][0]["_operator_links_sources"],
               [
                   
{'airflow.gcp.operators.bigquery.BigQueryConsoleIndexableLink': {'index': 0}},
                   
{'airflow.gcp.operators.bigquery.BigQueryConsoleIndexableLink': {'index': 1}}
               ]
           )
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to