Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
improve wording
  • Loading branch information
ticosax committed Jun 2, 2015
commit 34dc98e8ad7ff82f82e58c6bf2170bacfdb449c7
4 changes: 3 additions & 1 deletion tests/test_atomic_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ def setUp(self):
def tearDown(self):
connections.databases['default']['ATOMIC_REQUESTS'] = False

def test_error_rollback_transaction(self):
def test_generic_exception_delegate_transaction_management(self):
"""
Transaction is eventually managed by outer-most transaction atomic
block. DRF do not try to interfere here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not immediately sure what this means - would the test be different if we were using the test client, rather than calling the view directly with the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, views are wrapped by django.core.handlers.base.make_view_atomic(view) if one of the database defines ATOMIC_REQUESTS to True.

https://github.com/django/django/blob/master/django/core/handlers/base.py#L75

In the context of the test, I just check that drf's exception_handler doesn't intefere and let
django.core.handlers.base.make_view_atomic(view) do the job because the exception is raised.


We let django deal with the transaction when it will catch the Exception.
"""
request = factory.post('/')
with self.assertNumQueries(3):
Expand Down