Enable expansion of resource links in unit tests.
Review Request #12260 — Created April 26, 2022 and submitted
URLMapTransport
now supports the?expand=
query string argument,
allowing links to be expanded. When set, the transport will look up any
links listed and try to expand them in the resource before returning it
(and will also attempt to recurse into the expanded resources and expand
links within those).If an expanded URL is not registered, or it's mapped to a HTTP 404
response, then the expansion will be empty (None
or[]
).Normally, a list will be expanded to a list, and a dictionary to a
dictionary. This can be overridden to expand a dictionary into a 1-item
list of dictionaries (needed for review request drafts, due to a design
flaw in the original API). This is done through alink_expansion_types
dictionary that can be set during URL registration.
Made use of this with some in-development unit tests. All tests pass on
all supported versions of Python.Same for all existing tests as of this change.
Summary | ID |
---|---|
6bf5e29530c986ac4788d776b856da8d18fdeae2 |
- Change Summary:
-
Fixed to allow dictionary item resources to be expanded as 1-item lists of dictionaries (needed for review request drafts).
- Commits:
-
Summary ID cafcca35ac25ef62c952fb4e7075ddb4177ead56 76a7d03aa79b30c0d85525b4442f738533245a14
Checks run (2 succeeded)
- Change Summary:
-
Missing URLs or HTTP 404s are now considered empty expansions, just like with the normal API.
- Description:
-
URLMapTransport
now supports the?expand=
query string argument,allowing links to be expanded. When set, the transport will look up any links listed and try to expand them in the resource before returning it (and will also attempt to recurse into the expanded resources and expand links within those). ~ This requires that any expanded resources have their URLs registered
~ first. ~ If an expanded URL is not registered, or it's mapped to a HTTP 404
~ response, then the expansion will be empty ( None
or[]
).+ + Normally, a list will be expanded to a list, and a dictionary to a
+ dictionary. This can be overridden to expand a dictionary into a 1-item + list of dictionaries (needed for review request drafts, due to a design + flaw in the original API). This is done through a link_expansion_types
+ dictionary that can be set during URL registration. - Commits:
-
Summary ID 76a7d03aa79b30c0d85525b4442f738533245a14 e64989dc4b288dbb63f24827bad7465e736bdf7c
- Change Summary:
-
Fixed a bad format string.
- Commits:
-
Summary ID e64989dc4b288dbb63f24827bad7465e736bdf7c 60e2ffb03d14905c8776604d87c7054116a0083e