Skip to content

Commit

Permalink
test: update system tests for emulator (#97)
Browse files Browse the repository at this point in the history
* test: update system tests for emulator

* allow for emulator project to be set using GCLOUD_PROJECT

* blacken via nox

* use getenv to set default value

Co-authored-by: larkee <larkee@users.noreply.github.com>
  • Loading branch information
larkee and larkee authored Jun 16, 2020
1 parent 613d9c8 commit 33055e5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ def _list_instances():


def setUpModule():
Config.CLIENT = Client()
if USE_EMULATOR:
from google.auth.credentials import AnonymousCredentials

emulator_project = os.getenv("GCLOUD_PROJECT", "emulator-test-project")
Config.CLIENT = Client(
project=emulator_project, credentials=AnonymousCredentials()
)
else:
Config.CLIENT = Client()
retry = RetryErrors(exceptions.ServiceUnavailable)

configs = list(retry(Config.CLIENT.list_instance_configs)())
Expand Down Expand Up @@ -1215,7 +1223,6 @@ def test_transaction_batch_update_wo_statements(self):
with self.assertRaises(InvalidArgument):
transaction.batch_update([])

@unittest.skipIf(USE_EMULATOR, "Skipping partitioned DML")
def test_execute_partitioned_dml(self):
# [START spanner_test_dml_partioned_dml_update]
retry = RetryInstanceState(_has_all_ddl)
Expand Down Expand Up @@ -1329,6 +1336,7 @@ def test_transaction_query_w_concurrent_updates(self):
PKEY = "query_w_concurrent_updates"
self._transaction_concurrency_helper(self._query_w_concurrent_update, PKEY)

@unittest.skipIf(USE_EMULATOR, "Skipping concurrent transactions")
def test_transaction_read_w_abort(self):
retry = RetryInstanceState(_has_all_ddl)
retry(self._db.reload)()
Expand Down Expand Up @@ -1848,7 +1856,6 @@ def test_read_with_range_keys_and_index_open_open(self):
expected = [data[keyrow]] + data[start + 1 : end]
self.assertEqual(rows, expected)

@unittest.skipIf(USE_EMULATOR, "Skipping partitioned reads")
def test_partition_read_w_index(self):
row_count = 10
columns = self.COLUMNS[1], self.COLUMNS[2]
Expand Down

0 comments on commit 33055e5

Please sign in to comment.