Make it easier for callers to modify the root resource in unit tests.
Review Request #14580 — Created Sept. 8, 2025 and updated — Latest diff uploaded
We use as
URLMapTransport
the test transport in our unit tests, which
lets callers easily define response payloads for our API URLs in unit
tests.While writing some unit tests, I found that I couldn't reliably update
the root resource's payload. I could update the payload returned by the
root URL endpoint itself, but the server info resource and capabilities
attribute on the class would still use information from the default root
resource that gets set duringURLMapTransport.initialize()
. This
change allows callers to more easily change the root resource, and
dynamically reflect those changes in associated resources and attributes.This change also fixes two bugs:
We weren't setting the right object representation for the server info
resource. We were setting it to the outer payload when it should just
be the inner payload (e.g. the object representation, without the
'item_key' and 'stat' info).We weren't handling object representations that were callables. We
do handle payloads that are callables, but it's possible to have
object representations inside the payload that are callables too
(as is the case for the server info resource). We now process these
like we do for callable payloads.
- Used this change in an upcoming one that has unit tests that
previously crashed without these fixes. - Ran unit tests.