Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datastore): Add Datastore Admin API samples #4121

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test for entities import/export
  • Loading branch information
IlyaFaer committed Jun 26, 2020
commit a1bb45e0430151ae081907467759ab05dcf741a7
7 changes: 4 additions & 3 deletions datastore/cloud-client/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def export_entities(project_id, output_url_prefix):
client = datastore_admin_client.DatastoreAdminClient()

op = client.export_entities(project_id, output_url_prefix)
entities = op.result()
response = op.result()
IlyaFaer marked this conversation as resolved.
Show resolved Hide resolved

print("Entities were exported\n")
return entities
return response
# [END datastore_admin_entities_export]


Expand All @@ -50,9 +50,10 @@ def import_entities(project_id, input_url):
client = datastore_admin_client.DatastoreAdminClient()

op = client.import_entities(project_id, input_url)
op.result()
response = op.result()
IlyaFaer marked this conversation as resolved.
Show resolved Hide resolved

print("Entities were imported\n")
return response
# [END datastore_admin_entities_import]


Expand Down
9 changes: 9 additions & 0 deletions datastore/cloud-client/admin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

import os
import pytest
from retrying import retry

import admin

PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"]
BUCKET = os.environ["CLOUD_STORAGE_BUCKET"]


class TestDatastoreAdminSnippets:
Expand All @@ -35,3 +37,10 @@ def test_get_index(self):

def test_list_index(self):
assert admin.list_indexes(PROJECT)

@retry(stop_max_attempt_number=3, stop_max_delay=540000)
def test_export_import_entities(self):
response = admin.export_entities(PROJECT, "gs://" + BUCKET)
assert response

assert admin.import_entities(PROJECT, response.output_url)