Fix transaction errors when running review group tests
Review Request #9177 — Created Sept. 7, 2017 and submitted
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 … |
chipx86 | |
F401 'django.db.transaction' imported but unused |
reviewbot | |
F401 'django.db.IntegrityError' imported but unused |
reviewbot | |
I'm confused. Why are we creating a local site if with_local_site is False? |
david |
-
-
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
tocreate_review_group()
instead of usingwith_local_site=
. In fact, we save an additional query with the subsequent call. So I think this is the ideal way for multiple reasons.
- Change Summary:
-
Addressed Christian's issues
- Commit:
-
d757f862c994e11d8bf231dbb67cb8027244974784a2d2228261d87de59124d6dfb513a45003af80
- Diff:
-
Revision 2 (+19 -13)
- Commit:
-
84a2d2228261d87de59124d6dfb513a45003af804f2a4a488a8c47742496f233935aa341efdf44b8
- Diff:
-
Revision 3 (+18 -12)