This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new b167e3dbdd Resolve weaviate deprecations in tests (#39928)
b167e3dbdd is described below

commit b167e3dbddbc799789bc6be8d1f463fc3136136a
Author: Gopal Dirisala <[email protected]>
AuthorDate: Sat Jun 1 10:09:40 2024 +0530

    Resolve weaviate deprecations in tests (#39928)
    
    * Resolve weaviate deprecations in tests
    
    * Resolve weaviate deprecations in tests
---
 tests/deprecations_ignore.yml                      |  2 --
 .../providers/weaviate/operators/test_weaviate.py  | 30 +++++++++++++++++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml
index 146caf49b8..a2dbf9c9cb 100644
--- a/tests/deprecations_ignore.yml
+++ b/tests/deprecations_ignore.yml
@@ -647,5 +647,3 @@
 - 
tests/providers/tableau/hooks/test_tableau.py::TestTableauHook::test_get_conn_auth_via_token_and_site_in_init
 - 
tests/providers/tableau/hooks/test_tableau.py::TestTableauHook::test_get_conn_ssl_default
 - 
tests/providers/trino/operators/test_trino.py::test_execute_openlineage_events
-- 
tests/providers/weaviate/operators/test_weaviate.py::TestWeaviateIngestOperator::test_constructor
-- 
tests/providers/weaviate/operators/test_weaviate.py::TestWeaviateIngestOperator::test_execute_with_input_json
diff --git a/tests/providers/weaviate/operators/test_weaviate.py 
b/tests/providers/weaviate/operators/test_weaviate.py
index 643833d8fd..e147743d74 100644
--- a/tests/providers/weaviate/operators/test_weaviate.py
+++ b/tests/providers/weaviate/operators/test_weaviate.py
@@ -20,6 +20,7 @@ from unittest.mock import MagicMock, patch
 
 import pytest
 
+from airflow.exceptions import AirflowProviderDeprecationWarning
 from airflow.utils.task_instance_session import 
set_current_task_instance_session
 
 pytest.importorskip("weaviate")
@@ -37,7 +38,7 @@ class TestWeaviateIngestOperator:
             task_id="weaviate_task",
             conn_id="weaviate_conn",
             class_name="my_class",
-            input_json=[{"data": "sample_data"}],
+            input_data=[{"data": "sample_data"}],
         )
 
     def test_constructor(self, operator):
@@ -49,6 +50,33 @@ class TestWeaviateIngestOperator:
 
     
@patch("airflow.providers.weaviate.operators.weaviate.WeaviateIngestOperator.log")
     def test_execute_with_input_json(self, mock_log, operator):
+        with pytest.warns(
+            AirflowProviderDeprecationWarning,
+            match="Passing 'input_json' to WeaviateIngestOperator is 
deprecated and you should use 'input_data' instead",
+        ):
+            operator = WeaviateIngestOperator(
+                task_id="weaviate_task",
+                conn_id="weaviate_conn",
+                class_name="my_class",
+                input_json=[{"data": "sample_data"}],
+            )
+
+        operator.hook.batch_data = MagicMock()
+
+        operator.execute(context=None)
+
+        operator.hook.batch_data.assert_called_once_with(
+            class_name="my_class",
+            data=[{"data": "sample_data"}],
+            batch_config_params={},
+            vector_col="Vector",
+            uuid_col="id",
+            tenant=None,
+        )
+        mock_log.debug.assert_called_once_with("Input data: %s", [{"data": 
"sample_data"}])
+
+    
@patch("airflow.providers.weaviate.operators.weaviate.WeaviateIngestOperator.log")
+    def test_execute_with_input_data(self, mock_log, operator):
         operator.hook.batch_data = MagicMock()
 
         operator.execute(context=None)

Reply via email to