-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes entities for query tests persist to avoid flakiness.
This came about from conversations with @silvolu and @pcostell. Unfortunately, even if an entity has been stored and indexes built for 10+ minutes, the tests - test_query_simple_filter - test_query_multiple_filters are still flaky.
- Loading branch information
Showing
4 changed files
with
127 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"""Script to populate datastore with regression test data.""" | ||
|
||
|
||
from gcloud import datastore | ||
# This assumes the command is being run via tox hence the | ||
# repository root is the current directory. | ||
from regression import regression_utils | ||
|
||
|
||
KEY_PATHS = [ | ||
[{'kind': 'Character', 'name': 'Rickard'}], | ||
[{'kind': 'Character', 'name': 'Rickard'}, | ||
{'kind': 'Character', 'name': 'Eddard'}], | ||
[{'kind': 'Character', 'name': 'Catelyn'}], | ||
[{'kind': 'Character', 'name': 'Eddard'}, | ||
{'kind': 'Character', 'name': 'Arya'}], | ||
[{'kind': 'Character', 'name': 'Eddard'}, | ||
{'kind': 'Character', 'name': 'Sansa'}], | ||
[{'kind': 'Character', 'name': 'Eddard'}, | ||
{'kind': 'Character', 'name': 'Robb'}], | ||
[{'kind': 'Character', 'name': 'Eddard'}, | ||
{'kind': 'Character', 'name': 'Bran'}], | ||
[{'kind': 'Character', 'name': 'Eddard'}, | ||
{'kind': 'Character', 'name': 'Jon Snow'}], | ||
] | ||
CHARACTERS = [ | ||
{ | ||
'name': 'Rickard', | ||
'family': 'Stark', | ||
'appearances': 0, | ||
'alive': False, | ||
}, { | ||
'name': 'Eddard', | ||
'family': 'Stark', | ||
'appearances': 9, | ||
'alive': False, | ||
}, { | ||
'name': 'Catelyn', | ||
'family': ['Stark', 'Tully'], | ||
'appearances': 26, | ||
'alive': False, | ||
}, { | ||
'name': 'Arya', | ||
'family': 'Stark', | ||
'appearances': 33, | ||
'alive': True, | ||
}, { | ||
'name': 'Sansa', | ||
'family': 'Stark', | ||
'appearances': 31, | ||
'alive': True, | ||
}, { | ||
'name': 'Robb', | ||
'family': 'Stark', | ||
'appearances': 22, | ||
'alive': False, | ||
}, { | ||
'name': 'Bran', | ||
'family': 'Stark', | ||
'appearances': 25, | ||
'alive': True, | ||
}, { | ||
'name': 'Jon Snow', | ||
'family': 'Stark', | ||
'appearances': 32, | ||
'alive': True, | ||
}, | ||
] | ||
|
||
|
||
def add_characters(): | ||
dataset = regression_utils.get_dataset() | ||
with dataset.transaction(): | ||
for key_path, character in zip(KEY_PATHS, CHARACTERS): | ||
if key_path[-1]['name'] != character['name']: | ||
raise ValueError(('Character and key don\'t agree', | ||
key_path, character)) | ||
key = datastore.key.Key(path=key_path) | ||
entity = datastore.entity.Entity(dataset=dataset).key(key) | ||
entity.update(character) | ||
entity.save() | ||
print 'Adding Character %s %s' % (character['name'], | ||
character['family']) | ||
|
||
|
||
if __name__ == '__main__': | ||
add_characters() |
Oops, something went wrong.