From 07777ce4c87babb55571d73a2c817011f4c72cf5 Mon Sep 17 00:00:00 2001 From: Jonathan Simon Date: Fri, 29 Jun 2018 14:00:09 -0700 Subject: [PATCH] Fix python Cloud Spanner tests. [(#1548)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1548) * Fix python Cloud Spanner tests. * Lint. --- samples/samples/snippets_test.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/samples/samples/snippets_test.py b/samples/samples/snippets_test.py index 01c3b1da84..7d51e8fbb0 100644 --- a/samples/samples/snippets_test.py +++ b/samples/samples/snippets_test.py @@ -51,6 +51,20 @@ def temporary_database(spanner_instance): database_id = unique_database_id() snippets.create_database(SPANNER_INSTANCE, database_id) snippets.insert_data(SPANNER_INSTANCE, database_id) + snippets.write_struct_data(SPANNER_INSTANCE, database_id) + database = spanner_instance.database(database_id) + database.reload() + yield database + database.drop() + + +@pytest.fixture(scope='module') +def temporary_database_with_all_columns(spanner_instance): + database_id = unique_database_id() + snippets.create_database(SPANNER_INSTANCE, database_id) + snippets.insert_data(SPANNER_INSTANCE, database_id) + snippets.add_column(SPANNER_INSTANCE, database_id) + snippets.add_timestamp_column(SPANNER_INSTANCE, database_id) database = spanner_instance.database(database_id) database.reload() yield database @@ -213,10 +227,11 @@ def test_add_timestamp_column(temporary_database, capsys): @pytest.mark.slow -def test_update_data_with_timestamp(temporary_database, capsys): +def test_update_data_with_timestamp(temporary_database_with_all_columns, + capsys): snippets.update_data_with_timestamp( SPANNER_INSTANCE, - temporary_database.database_id) + temporary_database_with_all_columns.database_id) out, _ = capsys.readouterr()