-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spanner): nit sample data refactoring
- Loading branch information
1 parent
e401452
commit dc94850
Showing
2 changed files
with
13 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,14 @@ | |
(2, "Bharney", "Rhubble", "[email protected]"), | ||
(3, "Wylma", "Phlyntstone", "[email protected]"), | ||
) | ||
BATCH_WRITE_ROW_DATA = ( | ||
(1, "Phred", "Phlyntstone", "[email protected]"), | ||
(2, "Bharney", "Rhubble", "[email protected]"), | ||
(3, "Wylma", "Phlyntstone", "[email protected]"), | ||
(4, "Pebbles", "Phlyntstone", "[email protected]"), | ||
(5, "Betty", "Rhubble", "[email protected]"), | ||
(6, "Slate", "Stephenson", "[email protected]"), | ||
) | ||
ALL = spanner_v1.KeySet(all_=True) | ||
SQL = "SELECT * FROM contacts ORDER BY contact_id" | ||
|
||
|
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 |
---|---|---|
|
@@ -2523,23 +2523,17 @@ def test_partition_query(sessions_database, not_emulator): | |
|
||
def test_mutation_groups_insert_or_update_then_query(not_emulator, sessions_database): | ||
sd = _sample_data | ||
ROW_DATA = ( | ||
(1, "Phred", "Phlyntstone", "[email protected]"), | ||
(2, "Bharney", "Rhubble", "[email protected]"), | ||
(3, "Wylma", "Phlyntstone", "[email protected]"), | ||
(4, "Pebbles", "Phlyntstone", "[email protected]"), | ||
(5, "Betty", "Rhubble", "[email protected]"), | ||
(6, "Slate", "Stephenson", "[email protected]"), | ||
) | ||
num_groups = 3 | ||
num_mutations_per_group = len(ROW_DATA) // num_groups | ||
num_mutations_per_group = len(sd.BATCH_WRITE_ROW_DATA) // num_groups | ||
|
||
with sessions_database.mutation_groups() as groups: | ||
for i in range(num_groups): | ||
group = groups.group() | ||
for j in range(num_mutations_per_group): | ||
group.insert_or_update( | ||
sd.TABLE, sd.COLUMNS, [ROW_DATA[i * num_mutations_per_group + j]] | ||
sd.TABLE, | ||
sd.COLUMNS, | ||
[sd.BATCH_WRITE_ROW_DATA[i * num_mutations_per_group + j]], | ||
) | ||
# Response indexes received | ||
seen = collections.Counter() | ||
|
@@ -2556,7 +2550,7 @@ def test_mutation_groups_insert_or_update_then_query(not_emulator, sessions_data | |
with sessions_database.snapshot() as snapshot: | ||
rows = list(snapshot.execute_sql(sd.SQL)) | ||
|
||
sd._check_rows_data(rows, ROW_DATA) | ||
sd._check_rows_data(rows, sd.BATCH_WRITE_ROW_DATA) | ||
|
||
|
||
class FauxCall: | ||
|