Improve the testing methods for invoking API requests.
Review Request #10397 — Created Jan. 30, 2019 and submitted
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.
Summary | ID |
---|---|
fe3a16480127a130e909432ffcbed2caf8f5ba59 |
Description | From | Last Updated |
---|---|---|
The grammar in this warning is a little funky. Needs an "as" or "in" I think. |
david |
- Change Summary:
-
Improved a deprecation notice.
- Commits:
-
Summary ID 98dd3eb8e454a3e73996e807cc55e24f2ff6e37d fe3a16480127a130e909432ffcbed2caf8f5ba59 - Diff:
-
Revision 2 (+486 -482)