Improve test coverage and handling of input and errors in Review UIs.

Review Request #10717 — Created Sept. 16, 2019 and submitted

chipx86
Review Board
release-4.0.x
3fa894f...
reviewboard

The Review UI support had pretty minimal tests, which meant that some
recent issues weren't caught earlier in Python 3.x development. The few
tests we did have for the core ReviewUI and FileAttachmentReviewUI
were more about the sandboxing of some calls, which didn't really help
as much of the sandboxing applied the wrong approach (ignoring faults in
subclasses, resulting in harder-to-diagnose issues, rather than outright
failing).

Sandboxing is important when common code is calling into
extension-provided code, but in these cases we were dealing with
extension-provided code (subclasses of ReviewUI) calling other
extension-provided code (overridden methods of that same ReviewUI).

This removes all the old testing code, adding new more comprehensive and
correct tests for ReviewUI and FileAttachmentReviewUI. These live in
the standard reviewboard.reviews.tests directory, rather than the more
buried reviewboard.reviews.ui.tests (which is no more). The existing
ImageReviewUI (which could still use additional work) has been moved
into reviewboard.reviews.tests as well.

There were a few changes made to ReviewUI as a result of the tests.
The inline parameter (intended for rendering a ReviewUI within
something like the diff viewer, but never fully used in practice) now
does a better job of processing input in a request, and
get_comments_json() no longer tries to mark the string as safe
(leaving that up to the template).

Unit tests pass.

Description From Last Updated

F401 'django.test.client.RequestFactory' imported but unused

reviewbotreviewbot

F841 local variable 'attachment1' is assigned to but never used

reviewbotreviewbot

F841 local variable 'attachment3' is assigned to but never used

reviewbotreviewbot

F841 local variable 'draft' is assigned to but never used

reviewbotreviewbot

F821 undefined name 'has_usable_review_ui'

reviewbotreviewbot

F401 'django.test.client.RequestFactory' imported but unused

reviewbotreviewbot

F401 'djblets.testing.decorators.add_fixtures' imported but unused

reviewbotreviewbot

F401 'reviewboard.reviews.models.Review' imported but unused

reviewbotreviewbot

F401 'reviewboard.reviews.ui.base.register_ui' imported but unused

reviewbotreviewbot

F401 'reviewboard.reviews.ui.base.unregister_ui' imported but unused

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (7450c2c)
Loading...