Enable expansion of resource links in unit tests.

Review Request #12260 — Created April 26, 2022 and submitted

chipx86
RBTools
release-3.x
rbtools

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 a link_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
Enable expansion of resource links in unit tests.
Description From Last Updated

F401 'six' imported but unused

reviewbotreviewbot

F507 '...' % ... has 4 placeholder(s) but 3 substitution(s)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

Can we either make this conditional, or add assert link_key in payload['links'] above?

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
chipx86
Review request changed

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
-
Enable expansion of resource links in unit tests.
+
Enable expansion of resource links in unit tests.

Diff:

Revision 3 (+510 -30)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. rbtools/testing/api/payloads.py (Diff revision 4)
     
     

    Can we either make this conditional, or add assert link_key in payload['links'] above?

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.x (3d688be)
Loading...