Make the ID checks more restrict in the webapi test URL functions.
Review Request #5898 — Created May 29, 2014 and submitted
This enhances the logic of the various
get_*_url()
functions to be more
strict when they're willing to accept either an ID or an object.A new function,
_normalize_id()
, checks if the value is an ID or an
instance (or subclass) of the allowed class type. If it's not any of
these things, then aValueError
will be raised.This reduces the complexity of the code in the functions, prevents
duplication, and adds enhanced error checking.
Unit tests pass.
Description | From | Last Updated |
---|---|---|
'HostingServiceAccount' imported but unused |
reviewbot |
- Change Summary:
-
Removed an import that shouldn't have been there yet.
- Commit:
-
11c8977115a4f25baf77282da419176dbf58cf54779dee7c36013cf28dc253863cc6ba84be83e0fd
- Diff:
-
Revision 2 (+20 -12)
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/urls.py Ignored Files: