Sandboxed ReviewRequestApprovalHook and added test cases

Review Request #5677 — Created April 5, 2014 and submitted

Information

Review Board
master

Reviewers

Sandboxed ReviewRequestApprovalHook and added test cases

Added Sandbox Extension and test hook.

Unit testing, added to test suites in reviewboard/extensions/tests.py

Ran unit tests with and without the sandboxing

Description From Last Updated

We want two blank lines. You shouldn't alter lines unrelated to your change.

chipx86chipx86

This is missing a docstring.

chipx86chipx86

""" at the beginning.

chipx86chipx86

Missing a docstring. I don't understand the point of splitting this into two functions?

chipx86chipx86

This is defeating the purpose of the sandboxing work, since it's still crashing the program if there's an error. The …

chipx86chipx86

Please sort these in alphabetical order (errors before manager).

daviddavid

Please keep the things that are imported in alphabetical order.

daviddavid

I think you should subclass ReviewRequestApprovalHook and implement your own custom is_approved method (which raises some error), rather than relying …

daviddavid

This logging statement should include the extension name/id, as well as the contents of the exception that was raised.

daviddavid

We don't want to raise any errors here, we just want to log and continue with the other hooks.

daviddavid

This should be updated now, since is_approved is implemented.

daviddavid

The logging methods will format the string with any args that they get, so it's better to pass them in …

daviddavid

This should be "ReviewRequestApprovalHook"

daviddavid

The "throws an error" should be aligned with """ and not "Testing"

chipx86chipx86
chipx86
  1. 
      
  2. reviewboard/extensions/tests.py (Diff revision 1)
     
     
     
     
     

    We want two blank lines. You shouldn't alter lines unrelated to your change.

    1. Sorry, that was unintentional. I had originall something there and deleted it and accidentally deleted it down to one blank line.

  3. reviewboard/extensions/tests.py (Diff revision 1)
     
     

    This is missing a docstring.

  4. reviewboard/extensions/tests.py (Diff revision 1)
     
     

    """ at the beginning.

  5. reviewboard/extensions/tests.py (Diff revision 1)
     
     

    Missing a docstring.

    I don't understand the point of splitting this into two functions?

  6. This is defeating the purpose of the sandboxing work, since it's still crashing the program if there's an error. The whole point is to proceed so that normal operations can continue.

  7. 
      
ED
ED
david
  1. 
      
  2. reviewboard/extensions/tests.py (Diff revision 2)
     
     
     
     

    Please sort these in alphabetical order (errors before manager).

  3. reviewboard/extensions/tests.py (Diff revision 2)
     
     
     
     
     
     
     

    Please keep the things that are imported in alphabetical order.

  4. reviewboard/extensions/tests.py (Diff revision 2)
     
     

    I think you should subclass ReviewRequestApprovalHook and implement your own custom is_approved method (which raises some error), rather than relying on the fact that the default implementation currently raises NotImplementedError.

    ReviewRequestApprovalHook also does not take an entries parameter for its __init__ method, so you can just get rid of the whole entry part.

  5. This logging statement should include the extension name/id, as well as the contents of the exception that was raised.

  6. We don't want to raise any errors here, we just want to log and continue with the other hooks.

  7. 
      
ED
david
  1. 
      
  2. reviewboard/extensions/tests.py (Diff revision 3)
     
     
     

    This should be updated now, since is_approved is implemented.

  3. The logging methods will format the string with any args that they get, so it's better to pass them in as arguments instead of doing the format yourself (because then there will be two format operations). I'd also like to switch the format string around a bit--personally I think this is a little weird:

    Error calling function is_approved: Permission Denide: MyExtension

    Thus, this should look something like this:

    logging.error('Error when running ReviewRequestApprovalHook.'
                  'is_approved in extension "%s": %s',
                  extension.metadata['Name'], e, exc_info=1)
    
  4. 
      
ED
david
  1. One last comment, and then this looks good!

  2. reviewboard/extensions/tests.py (Diff revision 4)
     
     

    This should be "ReviewRequestApprovalHook"

  3. 
      
chipx86
  1. 
      
  2. reviewboard/extensions/tests.py (Diff revision 4)
     
     
     

    The "throws an error" should be aligned with """ and not "Testing"

  3. 
      
ED
ED
david
  1. Ship It!

  2. 
      
ED
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (b0c6560)
Loading...