Esempio n. 1
0
    def test_execute(self, mock_hook):
        op = CloudDatastoreCommitOperator(task_id="test_task",
                                          gcp_conn_id=CONN_ID,
                                          project_id=PROJECT_ID,
                                          body=BODY)
        op.execute({})

        mock_hook.assert_called_once_with(gcp_conn_id=CONN_ID)
        mock_hook.return_value.commit.assert_called_once_with(
            project_id=PROJECT_ID, body=BODY)
Esempio n. 2
0
                "key": KEYS[0],
                "properties": {
                    "string": {
                        "stringValue": "airflow is awesome!"
                    }
                },
            }
        }],
        "transaction":
        begin_transaction_commit.output,
    }
    # [END how_to_commit_def]

    # [START how_to_commit_task]
    commit_task = CloudDatastoreCommitOperator(task_id="commit_task",
                                               body=COMMIT_BODY,
                                               project_id=GCP_PROJECT_ID)
    # [END how_to_commit_task]

    allocate_ids >> begin_transaction_commit

    begin_transaction_query = CloudDatastoreBeginTransactionOperator(
        task_id="begin_transaction_query",
        transaction_options=TRANSACTION_OPTIONS,
        project_id=GCP_PROJECT_ID,
    )

    # [START how_to_query_def]
    QUERY = {
        "partitionId": {
            "projectId": GCP_PROJECT_ID,