Skip to content

Commit

Permalink
test: enable emulator tests for POSTGRESQL dialect (#1201)
Browse files Browse the repository at this point in the history
* 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 <larkee@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent a941adb commit 7cb68db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion google/cloud/spanner_v1/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 0 additions & 1 deletion tests/system/test_instance_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def test_create_instance(


def test_create_instance_with_processing_units(
not_emulator,
if_create_instance,
spanner_client,
instance_config,
Expand Down
8 changes: 5 additions & 3 deletions tests/system/test_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 7cb68db

Please sign in to comment.