Skip to content

Commit 3c91a01

Browse files
test(spanner): Refactoring testdata (googleapis#1184)
* chore(spanner): Issue1180# [Refactoring] Create a copy of samples/samples/testdata in tests * created copy in tests/system and test/unit * updated references * chore(spanner): Issue1180# [Refactoring] Create a copy of samples/samples/testdata in tests * updated formatting (nox -s blacken) --------- Co-authored-by: Sri Harsha CH <[email protected]>
1 parent b503fc9 commit 3c91a01

File tree

8 files changed

+100
-8
lines changed

8 files changed

+100
-8
lines changed

tests/system/_sample_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from google.api_core import datetime_helpers
1919
from google.cloud._helpers import UTC
2020
from google.cloud import spanner_v1
21-
from samples.samples.testdata import singer_pb2
21+
from .testdata import singer_pb2
2222

2323
TABLE = "contacts"
2424
COLUMNS = ("contact_id", "first_name", "last_name", "email")

tests/system/test_session_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from google.cloud.spanner_admin_database_v1 import DatabaseDialect
3030
from google.cloud._helpers import UTC
3131
from google.cloud.spanner_v1.data_types import JsonObject
32-
from samples.samples.testdata import singer_pb2
32+
from .testdata import singer_pb2
3333
from tests import _helpers as ot_helpers
3434
from . import _helpers
3535
from . import _sample_data

tests/system/testdata/singer.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package examples.spanner.music;
4+
5+
message SingerInfo {
6+
optional int64 singer_id = 1;
7+
optional string birth_date = 2;
8+
optional string nationality = 3;
9+
optional Genre genre = 4;
10+
}
11+
12+
enum Genre {
13+
POP = 0;
14+
JAZZ = 1;
15+
FOLK = 2;
16+
ROCK = 3;
17+
}

tests/system/testdata/singer_pb2.py

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/test__helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def test_w_json_None(self):
356356
def test_w_proto_message(self):
357357
from google.protobuf.struct_pb2 import Value
358358
import base64
359-
from samples.samples.testdata import singer_pb2
359+
from .testdata import singer_pb2
360360

361361
singer_info = singer_pb2.SingerInfo()
362362
expected = Value(string_value=base64.b64encode(singer_info.SerializeToString()))
@@ -366,7 +366,7 @@ def test_w_proto_message(self):
366366

367367
def test_w_proto_enum(self):
368368
from google.protobuf.struct_pb2 import Value
369-
from samples.samples.testdata import singer_pb2
369+
from .testdata import singer_pb2
370370

371371
value_pb = self._callFUT(singer_pb2.Genre.ROCK)
372372
self.assertIsInstance(value_pb, Value)
@@ -710,7 +710,7 @@ def test_w_proto_message(self):
710710
from google.cloud.spanner_v1 import Type
711711
from google.cloud.spanner_v1 import TypeCode
712712
import base64
713-
from samples.samples.testdata import singer_pb2
713+
from .testdata import singer_pb2
714714

715715
VALUE = singer_pb2.SingerInfo()
716716
field_type = Type(code=TypeCode.PROTO)
@@ -726,7 +726,7 @@ def test_w_proto_enum(self):
726726
from google.protobuf.struct_pb2 import Value
727727
from google.cloud.spanner_v1 import Type
728728
from google.cloud.spanner_v1 import TypeCode
729-
from samples.samples.testdata import singer_pb2
729+
from .testdata import singer_pb2
730730

731731
VALUE = "ROCK"
732732
field_type = Type(code=TypeCode.ENUM)

tests/unit/test_param_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_it(self):
9494
from google.cloud.spanner_v1 import Type
9595
from google.cloud.spanner_v1 import TypeCode
9696
from google.cloud.spanner_v1 import param_types
97-
from samples.samples.testdata import singer_pb2
97+
from .testdata import singer_pb2
9898

9999
singer_info = singer_pb2.SingerInfo()
100100
expected = Type(
@@ -111,7 +111,7 @@ def test_it(self):
111111
from google.cloud.spanner_v1 import Type
112112
from google.cloud.spanner_v1 import TypeCode
113113
from google.cloud.spanner_v1 import param_types
114-
from samples.samples.testdata import singer_pb2
114+
from .testdata import singer_pb2
115115

116116
singer_genre = singer_pb2.Genre
117117
expected = Type(

tests/unit/testdata/singer.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package examples.spanner.music;
4+
5+
message SingerInfo {
6+
optional int64 singer_id = 1;
7+
optional string birth_date = 2;
8+
optional string nationality = 3;
9+
optional Genre genre = 4;
10+
}
11+
12+
enum Genre {
13+
POP = 0;
14+
JAZZ = 1;
15+
FOLK = 2;
16+
ROCK = 3;
17+
}

tests/unit/testdata/singer_pb2.py

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)