fix: convert datetime back to proto for unit tests by busunkim96 · Pull Request #511 · googleapis/gapic-generator-python · GitHub
Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

fix: convert datetime back to proto for unit tests#511

Merged
software-dov merged 1 commit into
masterfrom
datetime-tests
Jul 10, 2020
Merged

fix: convert datetime back to proto for unit tests#511
software-dov merged 1 commit into
masterfrom
datetime-tests

Conversation

@busunkim96

@busunkim96 busunkim96 commented Jul 10, 2020

Copy link
Copy Markdown
Contributor

Closes #508

field.mock_value (passed to the request) is a protobuf timestamp/duration, but the call gets a datetime/timedelta object. From Type Marshaling this seems to be the expected behavior.

Proto Plus provides a service that converts between protocol buffer objects and native Python types (or the wrapper > types provided by this library).

This allows native Python objects to be used in place of protocol buffer messages where appropriate. In all cases, we return the native type, and are liberal on what we accept.

I tried protobuf's ToDatetime() but the resulting datetime doesn't have tzinfo. https://googleapis.dev/python/protobuf/latest/google/protobuf/timestamp_pb2.html#google.protobuf.timestamp_pb2.Timestamp.ToDatetime

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 10, 2020
@codecov

codecov Bot commented Jul 10, 2020

Copy link
Copy Markdown

@busunkim96 busunkim96 requested a review from software-dov July 10, 2020 07:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests with timestamps fail

3 participants