• 
      

    Read-only mode docs and unit tests for decorator and redirection

    Review Request #8847 — Created March 26, 2017 and submitted

    Information

    khp
    Review Board
    master

    Reviewers

    Read-only mode is a setting an admin can enable to prevent writes to
    the database. This can be used when the site is under maintenence or
    being upgraded. This commit adds some new documentation on how
    extension authors can utilize read-only mode in js and django.
    This commit also includes unit testing for the wrapped login_required
    decorator and its usage to redirect New Review Request and My
    Account when in read-only mode.

    Build docs - no problem
    Run python tests - pass except a couple that will be fixed in next commit

    Description From Last Updated

    "recommended that you enable read-only mode"

    brennie brennie

    "enabling read-only mode" instead of "putting the site in read-only mode"

    brennie brennie

    into. No comma here.

    brennie brennie

    "Review Board"

    brennie brennie

    The code should be aligned with the c in code-block, i.e., three spaces (yes, I know it's weird).

    brennie brennie

    "into"

    brennie brennie

    Just "API requests".

    brennie brennie

    How about "When the site is in read-only mode, only changes made to models by superusers will be propagated to …

    brennie brennie

    How about "When the site is in read-only mode, only changes made to models by superusers will be propagated to …

    brennie brennie

    Wrap readOnly in double-backtickcs so that gets marked as <code>.

    brennie brennie

    Likewise here.

    brennie brennie

    In JavaScript, this would actually be: if (conditional) { /* Comment */ } The code here also doesnt fit the …

    brennie brennie

    Undo this.

    brennie brennie

    We don't require docstrings for setUp, tearDown, etc.

    brennie brennie

    This can be moved into setUpClass, which only runs once per class, e.g. @classmethod def setUpClass(cls): super(LoginRequiredTest, cls).setUpClass() # ...

    brennie brennie

    This should be _mock_view_function. Also your args are in the wrong order.

    brennie brennie

    Care to split this up into user & super-user tests?

    brennie brennie

    Instead of "the decorator", say Testing @login_required. Same goes for all the tests here. No trailing periods in test docstrings.

    brennie brennie

    This comment is

    brennie brennie

    Care to split this up into user & super-user tests?

    brennie brennie

    Care to split this up into user & super-user tests?

    brennie brennie

    """ should be on next line.

    brennie brennie

    redefinition of unused 'test_my_account_does_not_redirect_when_not_read_only' from line 647

    reviewbot reviewbot

    This should be a phrase in the imperative mode, e.g. """Check response versus the expected value""" Missing args etc

    brennie brennie

    Can you split this into new tests?

    brennie brennie
    Checks run (1 failed, 1 succeeded, 1 failed with error)
    JSHint passed.
    PEP8 Style Checker internal error.
    Pyflakes failed.

    Pyflakes

    brennie
    1. 
        
    2. Show all issues

      "recommended that you enable read-only mode"

    3. Show all issues

      "enabling read-only mode" instead of "putting the site in read-only mode"

    4. Show all issues

      into.

      No comma here.

    5. Show all issues

      "Review Board"

    6. docs/manual/extending/extensions/class.rst (Diff revision 1)
       
       
       
       
       
       
       
      Show all issues

      The code should be aligned with the c in code-block, i.e., three spaces (yes, I know it's weird).

    7. Show all issues

      "into"

    8. Show all issues

      Just "API requests".

    9. Show all issues

      How about

      "When the site is in read-only mode, only changes made to models by superusers will be propagated to the server; changes made by all other users will be discarded."

    10. Show all issues

      How about

      "When the site is in read-only mode, only changes made to models by superusers will be propagated to the server; changes made by all other users will be discarded."

    11. Show all issues

      Wrap readOnly in double-backtickcs so that gets marked as <code>.

    12. docs/manual/extending/extensions/js-extensions.rst (Diff revision 1)
       
       
       
       
       
       
       
       
      Show all issues

      Likewise here.

    13. Show all issues

      In JavaScript, this would actually be:

      if (conditional) {
          /* Comment */
      }
      

      The code here also doesnt fit the above.

    14. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      Undo this.

    15. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      We don't require docstrings for setUp, tearDown, etc.

    16. reviewboard/accounts/tests.py (Diff revision 1)
       
       
       
      Show all issues

      This can be moved into setUpClass, which only runs once per class, e.g.

      @classmethod
      def setUpClass(cls):
          super(LoginRequiredTest, cls).setUpClass()
      
          # ...
      
    17. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      This should be _mock_view_function. Also your args are in the wrong order.

    18. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      Care to split this up into user & super-user tests?

    19. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      Instead of "the decorator", say Testing @login_required. Same goes for all the tests here.

      No trailing periods in test docstrings.

    20. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      This comment is

    21. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      Care to split this up into user & super-user tests?

    22. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      Care to split this up into user & super-user tests?

    23. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      """ should be on next line.

    24. reviewboard/accounts/tests.py (Diff revision 1)
       
       
      Show all issues

      This should be a phrase in the imperative mode, e.g.

      """Check response versus the expected value"""

      Missing args etc

    25. reviewboard/reviews/tests/test_views.py (Diff revision 1)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      Can you split this into new tests?

    26. 
        
    KH
    KH
    KH
    KH
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-4.0.x (768aab4)