Get rid of duplicate entries in the root resource's URI templates.
Review Request #12681 — Created Oct. 14, 2022 and submitted
In Review Board 5.0, we introduced new top level reviews and comment resources
for querying across all review requests. These resources shared the samename
as other reviews and comment resources. This exposed a problem where resources
that have the samename
will have their URI templates in the Root resource's
URI templates list overwritten by one another. Depending on the order that the
resources are added to the URI templates list, this can break the API by
replacing the URI template for a resource with another URI template that may
not behave in the same way or support the same methods as the previous one.This is a problem that requires more thought and a rethink of how we handle
our resources in general, but for now this change applies a solution that
ensures we keep as much compatibility with our previous API (Python 2.7
behavior) as possible.Instead of using the
name
attribute we use theuri_template_name
and
uri_template_name_plural
for the names of resources in the URI templates
list. This defaults to thename
, but can be set to something else to avoid
duplicates in the templates list, or toNone
to have the resource omitted
from the templates list. Resources that share the same name had their
uri_template_name
's changed to match how our previous API behaved and
to give access to the resources that were being overwritten.
- Manually compared the URI templates list to our URI templates list from
Python 2.7, made sure that the duplicate resources were renamed in a way that
does not break compatibility with the Python 2.7 list. - Ran all unit tests.
Summary | ID |
---|---|
0f1b52bf53a0412d78cec927586f867b4b504b97 |
Description | From | Last Updated |
---|---|---|
What do you think about having a unit test that compares the entire uri_templates dictionary in a resulting payload to … |
chipx86 | |
I made a comment on the Djblets side about possibly reusing name_plural. If that's worth adding there, then some of … |
chipx86 | |
No indentation here within "Returns". |
chipx86 | |
Should I put this in a settings.py setting? That way people could customize it if they wanted to. Also what … |
maubin | |
line too long (126 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (143 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (106 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (101 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (121 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (85 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (101 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (110 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (123 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (112 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (103 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (100 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (144 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (142 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (115 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (120 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (103 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (117 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (107 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (100 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (121 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (155 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (88 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (118 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (95 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (113 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (82 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (124 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (91 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
line too long (102 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
Let's call this expected_uri_templates. The above comment makes sense for right now, but that's more a technicality, as going forward … |
chipx86 |
-
-
What do you think about having a unit test that compares the entire
uri_templates
dictionary in a resulting payload to a known result? We'd then notice any differences immediately (even if not a conflict), and have a good record of what we should expect in that result. -
I made a comment on the Djblets side about possibly reusing
name_plural
. If that's worth adding there, then some of these get to go away. -
- Change Summary:
-
- Got rid of some specifically set
uri_template_name_plural
s after refactoring the way the property works. - Added a unit test for comparing URI templates to our Python 2.7 version of them.
- Got rid of some specifically set
- Commits:
-
Summary ID f75cc8490d711ebbf6d4b8c4b19e1733faa244fc 643bdfe377c2d24cba9f3ff140c38145a89a9f81 - Diff:
-
Revision 2 (+342 -36)
Checks run (1 failed, 1 succeeded)
flake8
-
Warning: Showing 30 of 57 failures.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Uses single quotes, wrapped strings and sorted the hardcoded URI templates for testing.
- Commits:
-
Summary ID 643bdfe377c2d24cba9f3ff140c38145a89a9f81 03c3b292d952d1a7658a713d5b4d9537fa57c05f - Diff:
-
Revision 3 (+552 -36)
Checks run (2 succeeded)
-
-
Let's call this
expected_uri_templates
.The above comment makes sense for right now, but that's more a technicality, as going forward this list is going to be updated.
What we're really wanting to check is whether the full list of URI templates in the API match exactly what we expect. Less so than a subset from 3.0, because we want to ensure there's no chance of this happening going forward either (even if Djblets is itself doing its own internal checking).
Any time we add a new resource, we'll want/need to change this as well.
Given that, I think the below dictionary building can also be simplified to just do a standard
assertEqual()
between the resulting URI templates and this dictionary.
- Change Summary:
-
Updated the
expected_uri_templates
dict and renamed some resources so that everything matches up with our 3.0, 4.0 and 5.0 APIs - Commits:
-
Summary ID 03c3b292d952d1a7658a713d5b4d9537fa57c05f 0f1b52bf53a0412d78cec927586f867b4b504b97 - Diff:
-
Revision 4 (+644 -36)