gapic-generator-python
gapic-generator-python copied to clipboard
In tests, explore creating descriptors from strings rather than helper functions to improve readability
From https://github.com/googleapis/gapic-generator-python/pull/1975#discussion_r1529207661 in PR https://github.com/googleapis/gapic-generator-python/pull/1975,
See suggestion below to improve readability of tests that require building descriptors from protos.
If it's trivial to read from a proto "file" (string) in tests, it might be simpler to simply encode the protofile inline rather than calling make_file_pb2
Something like this
proto_descriptor = make_protodescriptor("""
package xx;
message Foo {
string foo = 1;
}
""")
instead of
fd = (
make_file_pb2(
name="someexample.proto",
package="google.example.v1beta1",
messages=(
make_message_pb2(name="ExampleRequest", fields=fields),
make_message_pb2(name="ExampleResponse", fields=()),
),
services=(
descriptor_pb2.ServiceDescriptorProto(
name="SomeExample",
would improve readability