File tree Expand file tree Collapse file tree
datastore/tests/system/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,6 +80,31 @@ def remove_kind(kind, client):
8080 delete_chunks (client , results )
8181
8282
83+ def remove_all_entities (client ):
84+ # Clear datastore, ensure it's empty
85+ query = client .query (kind = '__kind__' )
86+ query .keys_only ()
87+
88+ kinds = [entity .key .id_or_name for entity in query .fetch ()]
89+
90+ for kind in kinds :
91+ query = client .query (kind = kind )
92+ query .keys_only ()
93+
94+ entities = list (query .fetch ())
95+
96+ # NOTE: Emulator doesn't support deleting more than 500 entities in a
97+ # single call
98+ delete_chunks (client , entities )
99+
100+ # Verify entities have been deleted
101+ query = client .query (kind = kind )
102+ query .keys_only ()
103+ result = list (query .fetch ())
104+
105+ assert (len (result ) == 0 )
106+
107+
83108def main ():
84109 client = datastore .Client ()
85110 kinds = sys .argv [1 :]
You can’t perform that action at this time.
0 commit comments