From 7cb68db98b611e6c0feb2a265ad246ab3ea8abf7 Mon Sep 17 00:00:00 2001 From: larkee <31196561+larkee@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:14:20 +1200 Subject: [PATCH] test: enable emulator tests for POSTGRESQL dialect (#1201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: enable emulator tests for POSTGRESQL dialect * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * test: update test fixture to not depend on other fixtures --------- Co-authored-by: larkee Co-authored-by: Owl Bot --- google/cloud/spanner_v1/database.py | 4 +++- tests/system/conftest.py | 9 +++++++++ tests/system/test_instance_api.py | 1 - tests/system/test_session_api.py | 8 +++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index 6bd4f3703e..f6c4ceb667 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -525,7 +525,9 @@ def reload(self): self._encryption_config = response.encryption_config self._encryption_info = response.encryption_info self._default_leader = response.default_leader - self._database_dialect = response.database_dialect + # Only update if the data is specific to avoid losing specificity. + if response.database_dialect != DatabaseDialect.DATABASE_DIALECT_UNSPECIFIED: + self._database_dialect = response.database_dialect self._enable_drop_protection = response.enable_drop_protection self._reconciling = response.reconciling diff --git a/tests/system/conftest.py b/tests/system/conftest.py index bf939cfa99..1337de4972 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -65,6 +65,15 @@ def not_google_standard_sql(database_dialect): ) +@pytest.fixture(scope="session") +def not_postgres_emulator(database_dialect): + if database_dialect == DatabaseDialect.POSTGRESQL and _helpers.USE_EMULATOR: + pytest.skip( + f"{_helpers.DATABASE_DIALECT_ENVVAR} set to POSTGRESQL and {_helpers.USE_EMULATOR_ENVVAR} set in " + "environment." + ) + + @pytest.fixture(scope="session") def database_dialect(): return ( diff --git a/tests/system/test_instance_api.py b/tests/system/test_instance_api.py index 6825e50721..fe962d2ccb 100644 --- a/tests/system/test_instance_api.py +++ b/tests/system/test_instance_api.py @@ -84,7 +84,6 @@ def test_create_instance( def test_create_instance_with_processing_units( - not_emulator, if_create_instance, spanner_client, instance_config, diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 31e38f967a..d0421d3a70 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -1195,7 +1195,9 @@ def unit_of_work(transaction): assert span.parent.span_id == span_list[-1].context.span_id -def test_execute_partitioned_dml(sessions_database, database_dialect): +def test_execute_partitioned_dml( + not_postgres_emulator, sessions_database, database_dialect +): # [START spanner_test_dml_partioned_dml_update] sd = _sample_data param_types = spanner_v1.param_types @@ -2420,7 +2422,7 @@ def test_execute_sql_w_json_bindings( def test_execute_sql_w_jsonb_bindings( - not_emulator, not_google_standard_sql, sessions_database, database_dialect + not_google_standard_sql, sessions_database, database_dialect ): _bind_test_helper( sessions_database, @@ -2432,7 +2434,7 @@ def test_execute_sql_w_jsonb_bindings( def test_execute_sql_w_oid_bindings( - not_emulator, not_google_standard_sql, sessions_database, database_dialect + not_google_standard_sql, sessions_database, database_dialect ): _bind_test_helper( sessions_database,