Update the GerritForm.clean() tests for cross-Django compatibility.
Review Request #10619 — Created July 8, 2019 and submitted — Latest diff uploaded
GerritForm.clean()
attempts to set agerrit_domain
key based on the
gerrit_url
that is provided, but otherwise doesn't perform any other
changes to the cleaned data. We had a unit test that checked that the
cleaned data (including domain) contained the values we expected, but
this posed problems on modern versions of Django, as theURLField
used
forgerrit_url
differed in its return value (the Django 1.6 version
includes a trailing slash while the 1.11 version does not).Rather than attempting to normalize the version in the test, or key off
expected values by version, we're instead changing the purpose of the
test. It no longer checks the entirety of the cleaned data, but rather
is checking thatgerrit_domain
is properly set based offgerrit_url
.
This avoids checking Django-specific results, sets a precedent in these
tests to have more specific unit tests for any custom keys added going
forward.
Unit tests pass on Django 1.6 and 1.11.