Formalize testing of diff parsing objects.

Review Request #12064 — Created Feb. 19, 2022 and submitted

Review Board

We have a lot of unit tests that test the results of diff parsing, and
they all do it slightly differently. Some assume the number of resulting
ParsedDiffFile objects. Some fail to test certain state. Most just
haven't been updated as new attributes have been added. Most that are
more comprehensive ideally wouldn't be, since it's hard to tell what
state they're explicitly checking for and what are considered defaults.

There are some updates coming to diff parsing for DiffX and for some
in-progress SCM implementations, such as symlink target storage. To
prepare for that, this change goes through and formalizes how we test
these objects.

A new reviewboard.diffviewer.testing.mixins.DiffParserTestingMixin
class provides some assertions for these objects:

  • assert_parsed_diff_file()
  • `assert_parsed_diff_change()
  • assert_parsed_diff()

These take in attributes to check on the objects. Default values are
checked if not explicitly provided.

All relevant unit tests now use these methods, ensuring parsing changes
or state updates don't regress anything or get missed going forward.

All unit tests passed.

Formalize testing of diff parsing objects.
  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (04348d6)