Fix transaction errors when running review group tests

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

Information

Review Board
release-3.0.x
4f2a4a4...

Reviewers

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.

Description From Last Updated

Could we use get_or_create()? That way, even though there's one additional query, we don't at all impact the transaction in …

chipx86chipx86

F401 'django.db.transaction' imported but unused

reviewbotreviewbot

F401 'django.db.IntegrityError' imported but unused

reviewbotreviewbot

I'm confused. Why are we creating a local site if with_local_site is False?

daviddavid
chipx86
  1. 
      
  2. Show all issues

    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. 
      
brennie
Review request changed
Change Summary:

Addressed Christian's issues

Commit:
d757f862c994e11d8bf231dbb67cb80272449747
84a2d2228261d87de59124d6dfb513a45003af80

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

brennie
chipx86
  1. Ship It!
  2. 
      
david
  1. 
      
  2. Show all issues

    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. 
      
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (4d9ac67)