You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/04/25 18:36:37 UTC
[airflow] 04/04: Update unit tests for Datastore operators
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit d9e7b6a940e3a5a84eee1c97ca32ef5fd4d22f42
Author: MaksYermak <ma...@gmail.com>
AuthorDate: Wed Apr 20 13:07:17 2022 +0200
Update unit tests for Datastore operators
---
tests/providers/google/cloud/operators/test_datastore.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tests/providers/google/cloud/operators/test_datastore.py b/tests/providers/google/cloud/operators/test_datastore.py
index ddc59a5135..75f3d2ac94 100644
--- a/tests/providers/google/cloud/operators/test_datastore.py
+++ b/tests/providers/google/cloud/operators/test_datastore.py
@@ -35,6 +35,7 @@ CONN_ID = "test-gcp-conn-id"
BODY = {"key", "value"}
TRANSACTION = "transaction-name"
BUCKET = "gs://test-bucket"
+OUTPUT_URL = f"{BUCKET}/entities_export_name/entities_export_name.overall_export_metadata"
FILE = "filename"
OPERATION_ID = "1234"
@@ -44,7 +45,10 @@ class TestCloudDatastoreExportEntitiesOperator:
def test_execute(self, mock_hook):
mock_hook.return_value.export_to_storage_bucket.return_value = {"name": OPERATION_ID}
mock_hook.return_value.poll_operation_until_done.return_value = {
- "metadata": {"common": {"state": "SUCCESSFUL"}}
+ "metadata": {"common": {"state": "SUCCESSFUL"}},
+ "response": {
+ "outputUrl": OUTPUT_URL,
+ },
}
op = CloudDatastoreExportEntitiesOperator(
@@ -53,7 +57,7 @@ class TestCloudDatastoreExportEntitiesOperator:
project_id=PROJECT_ID,
bucket=BUCKET,
)
- op.execute({})
+ op.execute(context={'ti': mock.MagicMock()})
mock_hook.assert_called_once_with(CONN_ID, None, impersonation_chain=None)
mock_hook.return_value.export_to_storage_bucket.assert_called_once_with(
@@ -82,7 +86,7 @@ class TestCloudDatastoreImportEntitiesOperator:
bucket=BUCKET,
file=FILE,
)
- op.execute({})
+ op.execute(context={'ti': mock.MagicMock()})
mock_hook.assert_called_once_with(CONN_ID, None, impersonation_chain=None)
mock_hook.return_value.import_from_storage_bucket.assert_called_once_with(
@@ -107,7 +111,7 @@ class TestCloudDatastoreAllocateIds:
project_id=PROJECT_ID,
partial_keys=partial_keys,
)
- op.execute({})
+ op.execute(context={'ti': mock.MagicMock()})
mock_hook.assert_called_once_with(gcp_conn_id=CONN_ID, impersonation_chain=None)
mock_hook.return_value.allocate_ids.assert_called_once_with(
@@ -138,7 +142,7 @@ class TestCloudDatastoreCommit:
op = CloudDatastoreCommitOperator(
task_id="test_task", gcp_conn_id=CONN_ID, project_id=PROJECT_ID, body=BODY
)
- op.execute({})
+ op.execute(context={'ti': mock.MagicMock()})
mock_hook.assert_called_once_with(gcp_conn_id=CONN_ID, impersonation_chain=None)
mock_hook.return_value.commit.assert_called_once_with(project_id=PROJECT_ID, body=BODY)