Skip to content

test(spanner): Refactoring testdata #1184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/system/_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from google.api_core import datetime_helpers
from google.cloud._helpers import UTC
from google.cloud import spanner_v1
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

TABLE = "contacts"
COLUMNS = ("contact_id", "first_name", "last_name", "email")
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from google.cloud.spanner_admin_database_v1 import DatabaseDialect
from google.cloud._helpers import UTC
from google.cloud.spanner_v1.data_types import JsonObject
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2
from tests import _helpers as ot_helpers
from . import _helpers
from . import _sample_data
Expand Down
17 changes: 17 additions & 0 deletions tests/system/testdata/singer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

package examples.spanner.music;

message SingerInfo {
optional int64 singer_id = 1;
optional string birth_date = 2;
optional string nationality = 3;
optional Genre genre = 4;
}

enum Genre {
POP = 0;
JAZZ = 1;
FOLK = 2;
ROCK = 3;
}
29 changes: 29 additions & 0 deletions tests/system/testdata/singer_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_w_json_None(self):
def test_w_proto_message(self):
from google.protobuf.struct_pb2 import Value
import base64
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

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

def test_w_proto_enum(self):
from google.protobuf.struct_pb2 import Value
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

value_pb = self._callFUT(singer_pb2.Genre.ROCK)
self.assertIsInstance(value_pb, Value)
Expand Down Expand Up @@ -710,7 +710,7 @@ def test_w_proto_message(self):
from google.cloud.spanner_v1 import Type
from google.cloud.spanner_v1 import TypeCode
import base64
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

VALUE = singer_pb2.SingerInfo()
field_type = Type(code=TypeCode.PROTO)
Expand All @@ -726,7 +726,7 @@ def test_w_proto_enum(self):
from google.protobuf.struct_pb2 import Value
from google.cloud.spanner_v1 import Type
from google.cloud.spanner_v1 import TypeCode
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

VALUE = "ROCK"
field_type = Type(code=TypeCode.ENUM)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_param_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_it(self):
from google.cloud.spanner_v1 import Type
from google.cloud.spanner_v1 import TypeCode
from google.cloud.spanner_v1 import param_types
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

singer_info = singer_pb2.SingerInfo()
expected = Type(
Expand All @@ -111,7 +111,7 @@ def test_it(self):
from google.cloud.spanner_v1 import Type
from google.cloud.spanner_v1 import TypeCode
from google.cloud.spanner_v1 import param_types
from samples.samples.testdata import singer_pb2
from .testdata import singer_pb2

singer_genre = singer_pb2.Genre
expected = Type(
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/testdata/singer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

package examples.spanner.music;

message SingerInfo {
optional int64 singer_id = 1;
optional string birth_date = 2;
optional string nationality = 3;
optional Genre genre = 4;
}

enum Genre {
POP = 0;
JAZZ = 1;
FOLK = 2;
ROCK = 3;
}
29 changes: 29 additions & 0 deletions tests/unit/testdata/singer_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.