Taragolis commented on code in PR #39752:
URL: https://github.com/apache/airflow/pull/39752#discussion_r1609551255


##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -379,63 +379,51 @@ def test_templating(self, 
create_task_instance_of_operator):
         assert task.impersonation_chain == "impersonation-chain"
 
 
-class TestAutoMLListColumnsSpecsOperator:
+class TestAutoMLTablesListColumnsSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListColumnSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         table_spec = "table_spec_id"
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListColumnSpecsOperator(
-            dataset_id=DATASET_ID,
-            table_spec_id=table_spec,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_column_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            table_spec_id=table_spec,
-            timeout=None,
-        )

Review Comment:
   Why this part is removed from tests?



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -379,63 +379,51 @@ def test_templating(self, 
create_task_instance_of_operator):
         assert task.impersonation_chain == "impersonation-chain"
 
 
-class TestAutoMLListColumnsSpecsOperator:
+class TestAutoMLTablesListColumnsSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListColumnSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         table_spec = "table_spec_id"
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListColumnSpecsOperator(
-            dataset_id=DATASET_ID,
-            table_spec_id=table_spec,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_column_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            table_spec_id=table_spec,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
+            _ = AutoMLTablesListColumnSpecsOperator(
+                dataset_id=DATASET_ID,
+                table_spec_id=table_spec,
+                location=GCP_LOCATION,
+                project_id=GCP_PROJECT_ID,
+                field_mask=MASK,
+                filter_=filter_,
+                page_size=page_size,
+                task_id=TASK_ID,
+            )
+        mock_hook.assert_not_called()
 
     @pytest.mark.db_test
     def test_templating(self, create_task_instance_of_operator):
-        ti = create_task_instance_of_operator(
-            AutoMLTablesListColumnSpecsOperator,
-            # Templated fields
-            dataset_id="{{ 'dataset-id' }}",
-            table_spec_id="{{ 'table-spec-id' }}",
-            field_mask="{{ 'field-mask' }}",
-            filter_="{{ 'filter-' }}",
-            location="{{ 'location' }}",
-            project_id="{{ 'project-id' }}",
-            impersonation_chain="{{ 'impersonation-chain' }}",
-            # Other parameters
-            dag_id="test_template_body_templating_dag",
-            task_id="test_template_body_templating_task",
-            execution_date=timezone.datetime(2024, 2, 1, tzinfo=timezone.utc),
-        )
-        ti.render_templates()
-        task: AutoMLTablesListColumnSpecsOperator = ti.task
-        assert task.dataset_id == "dataset-id"
-        assert task.table_spec_id == "table-spec-id"
-        assert task.field_mask == "field-mask"
-        assert task.filter_ == "filter-"
-        assert task.location == "location"
-        assert task.project_id == "project-id"
-        assert task.impersonation_chain == "impersonation-chain"
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):

Review Comment:
   ```suggestion
           with pytest.warns(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
   ```



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -737,53 +725,45 @@ def test_templating(self, 
create_task_instance_of_operator):
 
 
 class TestAutoMLTablesListTableSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListTableSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListTableSpecsOperator(
-            dataset_id=DATASET_ID,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_table_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):

Review Comment:
   ```suggestion
           with pytest.warns(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
   ```



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -737,53 +725,45 @@ def test_templating(self, 
create_task_instance_of_operator):
 
 
 class TestAutoMLTablesListTableSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListTableSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListTableSpecsOperator(
-            dataset_id=DATASET_ID,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_table_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            timeout=None,
-        )

Review Comment:
   Why this part is removed from tests?



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -379,63 +379,51 @@ def test_templating(self, 
create_task_instance_of_operator):
         assert task.impersonation_chain == "impersonation-chain"
 
 
-class TestAutoMLListColumnsSpecsOperator:
+class TestAutoMLTablesListColumnsSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListColumnSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         table_spec = "table_spec_id"
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListColumnSpecsOperator(
-            dataset_id=DATASET_ID,
-            table_spec_id=table_spec,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_column_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            table_spec_id=table_spec,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
+            _ = AutoMLTablesListColumnSpecsOperator(
+                dataset_id=DATASET_ID,
+                table_spec_id=table_spec,
+                location=GCP_LOCATION,
+                project_id=GCP_PROJECT_ID,
+                field_mask=MASK,
+                filter_=filter_,
+                page_size=page_size,
+                task_id=TASK_ID,
+            )
+        mock_hook.assert_not_called()
 
     @pytest.mark.db_test
     def test_templating(self, create_task_instance_of_operator):
-        ti = create_task_instance_of_operator(
-            AutoMLTablesListColumnSpecsOperator,
-            # Templated fields
-            dataset_id="{{ 'dataset-id' }}",
-            table_spec_id="{{ 'table-spec-id' }}",
-            field_mask="{{ 'field-mask' }}",
-            filter_="{{ 'filter-' }}",
-            location="{{ 'location' }}",
-            project_id="{{ 'project-id' }}",
-            impersonation_chain="{{ 'impersonation-chain' }}",
-            # Other parameters
-            dag_id="test_template_body_templating_dag",
-            task_id="test_template_body_templating_task",
-            execution_date=timezone.datetime(2024, 2, 1, tzinfo=timezone.utc),
-        )
-        ti.render_templates()
-        task: AutoMLTablesListColumnSpecsOperator = ti.task
-        assert task.dataset_id == "dataset-id"
-        assert task.table_spec_id == "table-spec-id"
-        assert task.field_mask == "field-mask"
-        assert task.filter_ == "filter-"
-        assert task.location == "location"
-        assert task.project_id == "project-id"
-        assert task.impersonation_chain == "impersonation-chain"

Review Comment:
   Why this part is removed from tests?



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -737,53 +725,45 @@ def test_templating(self, 
create_task_instance_of_operator):
 
 
 class TestAutoMLTablesListTableSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListTableSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListTableSpecsOperator(
-            dataset_id=DATASET_ID,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_table_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
+            _ = AutoMLTablesListTableSpecsOperator(
+                dataset_id=DATASET_ID,
+                location=GCP_LOCATION,
+                project_id=GCP_PROJECT_ID,
+                filter_=filter_,
+                page_size=page_size,
+                task_id=TASK_ID,
+            )
+        mock_hook.assert_not_called()
 
     @pytest.mark.db_test
     def test_templating(self, create_task_instance_of_operator):
-        ti = create_task_instance_of_operator(
-            AutoMLTablesListTableSpecsOperator,
-            # Templated fields
-            dataset_id="{{ 'dataset-id' }}",
-            filter_="{{ 'filter-' }}",
-            location="{{ 'location' }}",
-            project_id="{{ 'project-id' }}",
-            impersonation_chain="{{ 'impersonation-chain' }}",
-            # Other parameters
-            dag_id="test_template_body_templating_dag",
-            task_id="test_template_body_templating_task",
-            execution_date=timezone.datetime(2024, 2, 1, tzinfo=timezone.utc),
-        )
-        ti.render_templates()
-        task: AutoMLTablesListTableSpecsOperator = ti.task
-        assert task.dataset_id == "dataset-id"
-        assert task.filter_ == "filter-"
-        assert task.location == "location"
-        assert task.project_id == "project-id"
-        assert task.impersonation_chain == "impersonation-chain"

Review Comment:
   Why this part is removed from tests?



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -379,63 +379,51 @@ def test_templating(self, 
create_task_instance_of_operator):
         assert task.impersonation_chain == "impersonation-chain"
 
 
-class TestAutoMLListColumnsSpecsOperator:
+class TestAutoMLTablesListColumnsSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListColumnSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         table_spec = "table_spec_id"
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListColumnSpecsOperator(
-            dataset_id=DATASET_ID,
-            table_spec_id=table_spec,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_column_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            field_mask=MASK,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            table_spec_id=table_spec,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):

Review Comment:
   Just wondering why you consider to use `pytest.raises` here instead of 
[`pytest.warns`](https://docs.pytest.org/en/stable/reference/reference.html#pytest-warns),
 I guess if it failed pytest plugin should suggest to follow 
https://github.com/apache/airflow/blob/main/contributing-docs/testing/unit_tests.rst#handling-warnings
   
   ```suggestion
           with pytest.warns(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
   ```



##########
tests/providers/google/cloud/operators/test_automl.py:
##########
@@ -737,53 +725,45 @@ def test_templating(self, 
create_task_instance_of_operator):
 
 
 class TestAutoMLTablesListTableSpecsOperator:
+    expected_deprecation_warning = (
+        "Class `AutoMLTablesListTableSpecsOperator` has been deprecated and 
will be removed after 31.12.2024. "
+        "AutoML platform no longer supports tabular datasets after its 
integration with Cloud Translation and Vertex AI. "
+        "Please refer to 
https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
+        "https://cloud.google.com/translate/docs/advanced/automl-upgrade for 
more info about available alternatives."
+    )
+
     
@mock.patch("airflow.providers.google.cloud.operators.automl.CloudAutoMLHook")
     def test_execute(self, mock_hook):
         filter_ = "filter"
         page_size = 42
 
-        op = AutoMLTablesListTableSpecsOperator(
-            dataset_id=DATASET_ID,
-            location=GCP_LOCATION,
-            project_id=GCP_PROJECT_ID,
-            filter_=filter_,
-            page_size=page_size,
-            task_id=TASK_ID,
-        )
-        op.execute(context=mock.MagicMock())
-        mock_hook.return_value.list_table_specs.assert_called_once_with(
-            dataset_id=DATASET_ID,
-            filter_=filter_,
-            location=GCP_LOCATION,
-            metadata=(),
-            page_size=page_size,
-            project_id=GCP_PROJECT_ID,
-            retry=DEFAULT,
-            timeout=None,
-        )
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
+            _ = AutoMLTablesListTableSpecsOperator(
+                dataset_id=DATASET_ID,
+                location=GCP_LOCATION,
+                project_id=GCP_PROJECT_ID,
+                filter_=filter_,
+                page_size=page_size,
+                task_id=TASK_ID,
+            )
+        mock_hook.assert_not_called()
 
     @pytest.mark.db_test
     def test_templating(self, create_task_instance_of_operator):
-        ti = create_task_instance_of_operator(
-            AutoMLTablesListTableSpecsOperator,
-            # Templated fields
-            dataset_id="{{ 'dataset-id' }}",
-            filter_="{{ 'filter-' }}",
-            location="{{ 'location' }}",
-            project_id="{{ 'project-id' }}",
-            impersonation_chain="{{ 'impersonation-chain' }}",
-            # Other parameters
-            dag_id="test_template_body_templating_dag",
-            task_id="test_template_body_templating_task",
-            execution_date=timezone.datetime(2024, 2, 1, tzinfo=timezone.utc),
-        )
-        ti.render_templates()
-        task: AutoMLTablesListTableSpecsOperator = ti.task
-        assert task.dataset_id == "dataset-id"
-        assert task.filter_ == "filter-"
-        assert task.location == "location"
-        assert task.project_id == "project-id"
-        assert task.impersonation_chain == "impersonation-chain"
+        with pytest.raises(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):

Review Comment:
   ```suggestion
           with pytest.warns(AirflowProviderDeprecationWarning, 
match=self.expected_deprecation_warning):
   ```



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