googleapis / gapic-generator-python

Generate Python API client libraries from Protocol Buffers.
Apache License 2.0
122 stars 68 forks source link

Determine if mock_value should populate multiple nested fields #1956

Open parthea opened 8 months ago

parthea commented 8 months ago

The mock_value method which is show below is used for test purposes. There is a limitation where mock_value only populates a single nested field in a message. When a method signature contains multiple nested fields, this leads to failures in generated tests like https://github.com/googleapis/gapic-generator-python/issues/1955.

https://github.com/googleapis/gapic-generator-python/blob/af3396665b40c748423599c4658ada8685f7bd36/gapic/schema/wrappers.py#L176-L184

https://github.com/googleapis/gapic-generator-python/blob/af3396665b40c748423599c4658ada8685f7bd36/gapic/schema/wrappers.py#L202-L210

field.mock_value shown below only includes a single nested field and this is appears to be as intended based on the comment If this is another message, set one value on the message..

https://github.com/googleapis/gapic-generator-python/blob/af3396665b40c748423599c4658ada8685f7bd36/gapic/templates/tests/unit/gapic/%25name_%25version/%25sub/test_macros.j2#L431

parthea commented 6 months ago

Bumping to p3 as we don't currently have any APIs that are blocked on https://github.com/googleapis/gapic-generator-python/issues/1955