bradleybonitatibus opened a new issue #19977:
URL: https://github.com/apache/airflow/issues/19977


   ### Apache Airflow Provider(s)
   
   google
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-google==5.1.0
   
   ### Apache Airflow version
   
   2.1.4
   
   ### Operating System
   
   MacOS BigSur 11.6
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   `tox4` virtual environment
   
   ### What happened
   
   1) Unit testing some DAG task operators with `asset op.dry_run() is None`
   2) `AttributeError` is raised when `baseoperator` iterates through 
`template_fields` and calls `getattr`
   
   ```
       def dry_run(self) -> None:
           """Performs dry run for the operator - just render template 
fields."""
           self.log.info('Dry run')
           for field in self.template_fields:
               content = getattr(self, field)
   ```
   3) Caused by deprecated `destination_bucket` argument, is being assigned to 
`self.bucket_name`
   
   
   ### What you expected to happen
   
   Calling `op.dry_run()` should return None and not raise any exceptions.
   
   The templated fields contains deprecated arguments (`destination_bucket`, 
`destination_object`), and aren't initialized in the init method for the class.
   
   The base operator loops through these templated fields, but since 
`GoogleDriveToGCSOperator` does not initialize `self.destination_bucket` or 
`self.destination_object`, it raises an `AttributeError`
   
   ### How to reproduce
   
   ```python
   
   from airflow.providers.google.cloud.transfers import gdrive_to_gcs
   
   
   # pytest fixtures included as arguments
   # won't include for brevity, but can provide if necessary
   def test_gdrive_to_gcs_transfer(
           test_dag,
           mock_gcp_default_conn,
           patched_log_entry,
           today
   ):
       op = gdrive_to_gcs.GoogleDriveToGCSOperator(
           task_id="test_gcs_to_gdrive_transfer",
           dag=test_dag,
           bucket_name="some-other-bucket",
           object_name="thing_i_want_to_copy.csv",
           file_name="my_file.csv",
           folder_id="my_folder",
           drive_id="some_drive_id",
       )
       assert op.dry_run() is None
   ```
   
   ### Anything else
   
   Not sure where it would be appropriate to address this issue since the 
deprecated fields support backward compatibility to previous versions of the 
operator.
   
   This is my first time contributing to the project, but hope this is helpful.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]


Reply via email to