Standardize communicating with the Review Board API.

Review Request #11535 — Created March 19, 2021 and submitted

Information

ReviewBot
release-3.0.x

Reviewers

We had a few spots where we constructed a RBClient and fetching the
API root, each time passing in a string for the user agent and for the
cookie path, with TODO comments saying we should consolidate this
information.

This change does just that. It introduces rbtools.utils.api, which
provides get_api_root(). This takes in a server URL and credentials,
and returns the root resource.

That handles RBClient construction, passing in a user agent (now set
to ReviewBot/<version>, rather than just ReviewBot) and a cookies
file.

The cookies file still needs to be made configurable, but that will be
handled separately.

Unit tests have not been added for this new function, since it's pretty
well covered by existing tests (both in Review Bot and RBTools), and
there's not much happening beyond passing in arguments and called
pre-tested methods.

Unit tests pass on Python 2.7 and 3.x.

Summary ID
Standardize communicating with the Review Board API.
We had a few spots where we constructed a `RBClient` and fetching the API root, each time passing in a string for the user agent and for the cookie path, with TODO comments saying we should consolidate this information. This change does just that. It introduces `rbtools.utils.api`, which provides `get_api_root()`. This takes in a server URL and credentials, and returns the root resource. That handles `RBClient` construction, passing in a user agent (now set to `ReviewBot/<version>`, rather than just `ReviewBot`) and a cookies file. The cookies file still needs to be made configurable, but that will be handled separately. Unit tests have not been added for this new function, since it's pretty well covered by existing tests (both in Review Bot and RBTools), and there's not much happening beyond passing in arguments and called pre-tested methods.
063cd10a7fb72ec58705136789b508c572a2e635
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (ff0acee)