Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions system_tests/clear_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


_implicit_environ._DATASET_ENV_VAR_NAME = 'GCLOUD_TESTS_DATASET_ID'
CLIENT = datastore.Client()


FETCH_MAX = 20
Expand All @@ -36,7 +37,7 @@

def fetch_keys(kind, fetch_max=FETCH_MAX, query=None, cursor=None):
if query is None:
query = datastore.Query(kind=kind, projection=['__key__'])
query = CLIENT.query(kind=kind, projection=['__key__'])

iterator = query.fetch(limit=fetch_max, start_cursor=cursor)

Expand Down Expand Up @@ -65,7 +66,7 @@ def remove_kind(kind):
return

delete_outside_transaction = False
with datastore.Transaction():
with CLIENT.transaction():
# Now that we have all results, we seek to delete.
print('Deleting keys:')
print(results)
Expand All @@ -74,10 +75,10 @@ def remove_kind(kind):
if len(ancestors) > TRANSACTION_MAX_GROUPS:
delete_outside_transaction = True
else:
datastore.delete_multi([result.key for result in results])
CLIENT.delete_multi([result.key for result in results])

if delete_outside_transaction:
datastore.delete_multi([result.key for result in results])
CLIENT.delete_multi([result.key for result in results])


def remove_all_entities():
Expand Down
5 changes: 3 additions & 2 deletions system_tests/populate_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


_implicit_environ._DATASET_ENV_VAR_NAME = 'GCLOUD_TESTS_DATASET_ID'
CLIENT = datastore.Client()


ANCESTOR = ('Book', 'GoT')
Expand Down Expand Up @@ -82,12 +83,12 @@


def add_characters():
with datastore.Transaction() as xact:
with CLIENT.transaction() as xact:
for key_path, character in zip(KEY_PATHS, CHARACTERS):
if key_path[-1] != character['name']:
raise ValueError(('Character and key don\'t agree',
key_path, character))
entity = datastore.Entity(key=datastore.Key(*key_path))
entity = datastore.Entity(key=CLIENT.key(*key_path))
entity.update(character)
xact.put(entity)
print('Adding Character %s %s' % (character['name'],
Expand Down