Improve the testing methods for invoking API requests.
Review Request #10397 — Created Jan. 30, 2019 and submitted — Latest diff uploaded
This is a rewrite of the various API invocation methods for unit tests
that simplifies them, moving all common logic to a single function
(api_call
, formerly_api_func_wrapper
). The various wrapper methods
now just invoke this method with some default arguments. Subclasses can
overrideapi_call
to add further logic, and the other methods will
benefit from it.These also now allow for specifying the number of SQL queries that an
API handler was expected to have run. This is done by passing
expected_num_queries=
to any of the API invocation methods.The new methods are backwards-compatible with the old ones, so long as
the various keyword arguments (anything pastpath
andquery
) weren't
passed as positional arguments. However, it does rename thequery
argument todata
, which makes more sense for non-GET requests. If
passed as a positional argument, nothing changes, but if passed as a
keyword argument, a warning will be emitted and the argument will be
converted.
Djblets and Review Board unit tests pass.