Fix transaction errors when running review group tests

Review Request #9177 - Created Sept. 7, 2017 and submitted

Barret Rennie
Review Board
release-3.0.x
4f2a4a4...
reviewboard

When running unit tests, if an IntegrityError error is raised (even if
it is caught), it will break the transaction the unit test runs in.
Therefore, we have to run the potentially exception-raising code in its
own atomic block to avoid this happening.

This also changes a mistaken reference to self.self.local_site_name.

Ran unit tests.

  • 0
  • 0
  • 3
  • 1
  • 4
Description From Last Updated
Christian Hammond
  1. 
      
  2. Could we use get_or_create()? That way, even though there's one additional query, we don't at all impact the transaction in any form.

    Actually, we get that query back if we pass in the returned LocalSite to create_review_group() instead of using with_local_site=. In fact, we save an additional query with the subsequent call. So I think this is the ideal way for multiple reasons.

  3. 
      
Barret Rennie
Review request changed

Change Summary:

Addressed Christian's issues

Commit:

-d757f862c994e11d8bf231dbb67cb80272449747
+84a2d2228261d87de59124d6dfb513a45003af80

Diff:

Revision 2 (+19 -13)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

Barret Rennie
Christian Hammond
  1. Ship It!
  2. 
      
David Trowbridge
  1. 
      
  2. I'm confused. Why are we creating a local site if with_local_site is False?

    1. with_local_site indicates whether or not the created review group is bound to the local site. We always create a review group bound to the local site and none not bound to it so we can check we are returning the correct groups.

  3. 
      
Barret Rennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (4d9ac67)
Loading...