Skip to content

Commit 43f9d19

Browse files
committed
fix tests
1 parent e273cbd commit 43f9d19

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

samples/generated/noxfile.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
160160
# format = isort + black
161161
#
162162

163+
163164
@nox.session
164165
def format(session: nox.sessions.Session) -> None:
165166
"""
@@ -187,7 +188,9 @@ def _session_tests(
187188
session: nox.sessions.Session, post_install: Callable = None
188189
) -> None:
189190
# check for presence of tests
190-
test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob("**/test_*.py", recursive=True)
191+
test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob(
192+
"**/test_*.py", recursive=True
193+
)
191194
test_list.extend(glob.glob("**/tests", recursive=True))
192195

193196
if len(test_list) == 0:
@@ -209,9 +212,7 @@ def _session_tests(
209212

210213
if os.path.exists("requirements-test.txt"):
211214
if os.path.exists("constraints-test.txt"):
212-
session.install(
213-
"-r", "requirements-test.txt", "-c", "constraints-test.txt"
214-
)
215+
session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
215216
else:
216217
session.install("-r", "requirements-test.txt")
217218
with open("requirements-test.txt") as rtfile:
@@ -224,9 +225,9 @@ def _session_tests(
224225
post_install(session)
225226

226227
if "pytest-parallel" in packages:
227-
concurrent_args.extend(['--workers', 'auto', '--tests-per-worker', 'auto'])
228+
concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"])
228229
elif "pytest-xdist" in packages:
229-
concurrent_args.extend(['-n', 'auto'])
230+
concurrent_args.extend(["-n", "auto"])
230231

231232
session.run(
232233
"pytest",
@@ -256,7 +257,7 @@ def py(session: nox.sessions.Session) -> None:
256257

257258

258259
def _get_repo_root() -> Optional[str]:
259-
""" Returns the root folder of the project. """
260+
"""Returns the root folder of the project."""
260261
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
261262
p = Path(os.getcwd())
262263
for i in range(10):

samples/generated/snippets.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424

2525
from google.cloud import spanner
2626
from google.cloud.spanner_admin_instance_v1.types import spanner_instance_admin
27-
from google.cloud.spanner_v1 import param_types
28-
from google.type import expr_pb2
29-
from google.iam.v1 import policy_pb2
30-
from google.cloud.spanner_v1.data_types import JsonObject
31-
from google.protobuf import field_mask_pb2 # type: ignore
3227

3328
OPERATION_TIMEOUT_SECONDS = 240
3429

@@ -71,31 +66,35 @@ def create_database_with_default_leader(instance_id, database_id, default_leader
7166
"""Creates a database with tables with a default leader."""
7267
spanner_client = spanner.Client()
7368
operation = spanner_client.database_admin_api.create_database(
74-
parent="projects/{}/instances/{}".format(spanner_client.project, instance_id),
75-
create_statement="CREATE DATABASE '{}'".format(database_id),
76-
extra_statements=[
77-
"""CREATE TABLE Singers (
78-
SingerId INT64 NOT NULL,
79-
FirstName STRING(1024),
80-
LastName STRING(1024),
81-
SingerInfo BYTES(MAX)
82-
) PRIMARY KEY (SingerId)""",
83-
"""CREATE TABLE Albums (
84-
SingerId INT64 NOT NULL,
85-
AlbumId INT64 NOT NULL,
86-
AlbumTitle STRING(MAX)
87-
) PRIMARY KEY (SingerId, AlbumId),
88-
INTERLEAVE IN PARENT Singers ON DELETE CASCADE""",
89-
"ALTER DATABASE {}"
90-
" SET OPTIONS (default_leader = '{}')".format(database_id, default_leader),
91-
],
69+
request={
70+
"parent": "projects/{}/instances/{}".format(
71+
spanner_client.project, instance_id
72+
),
73+
"create_statement": "CREATE DATABASE {}".format(database_id),
74+
"extra_statements": [
75+
"""CREATE TABLE Singers (
76+
SingerId INT64 NOT NULL,
77+
FirstName STRING(1024),
78+
LastName STRING(1024),
79+
SingerInfo BYTES(MAX)
80+
) PRIMARY KEY (SingerId)""",
81+
"""CREATE TABLE Albums (
82+
SingerId INT64 NOT NULL,
83+
AlbumId INT64 NOT NULL,
84+
AlbumTitle STRING(MAX)
85+
) PRIMARY KEY (SingerId, AlbumId),
86+
INTERLEAVE IN PARENT Singers ON DELETE CASCADE""",
87+
"ALTER DATABASE {}"
88+
" SET OPTIONS (default_leader = '{}')".format(
89+
database_id, default_leader
90+
),
91+
],
92+
},
9293
)
9394

9495
print("Waiting for operation to complete...")
9596
database = operation.result(OPERATION_TIMEOUT_SECONDS)
9697

97-
database.reload()
98-
9998
print(
10099
"Database {} created with default leader {}".format(
101100
database.name, database.default_leader

0 commit comments

Comments
 (0)