Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
b015ae99
Commit
b015ae99
authored
Jun 08, 2015
by
hellysmile
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline @transaction.non_atomic_requests for Django<1.6.
parent
c292b3d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
tests/test_atomic_requests.py
+10
-10
No files found.
tests/test_atomic_requests.py
View file @
b015ae99
...
@@ -33,16 +33,6 @@ class APIExceptionView(APIView):
...
@@ -33,16 +33,6 @@ class APIExceptionView(APIView):
raise
APIException
raise
APIException
class
NonAtomicAPIExceptionView
(
APIView
):
@method_decorator
(
transaction
.
non_atomic_requests
)
def
dispatch
(
self
,
*
args
,
**
kwargs
):
return
super
(
NonAtomicAPIExceptionView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
BasicModel
.
objects
.
create
()
raise
PermissionDenied
@skipUnless
(
connection
.
features
.
uses_savepoints
,
@skipUnless
(
connection
.
features
.
uses_savepoints
,
"'atomic' requires transactions and savepoints."
)
"'atomic' requires transactions and savepoints."
)
class
DBTransactionTests
(
TestCase
):
class
DBTransactionTests
(
TestCase
):
...
@@ -125,6 +115,16 @@ class DBTransactionAPIExceptionTests(TestCase):
...
@@ -125,6 +115,16 @@ class DBTransactionAPIExceptionTests(TestCase):
"'atomic' requires transactions and savepoints."
)
"'atomic' requires transactions and savepoints."
)
class
NonAtomicDBTransactionAPIExceptionTests
(
TestCase
):
class
NonAtomicDBTransactionAPIExceptionTests
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
# only Django >= 1.6 provides @transaction.non_atomic_requests
class
NonAtomicAPIExceptionView
(
APIView
):
@method_decorator
(
transaction
.
non_atomic_requests
)
def
dispatch
(
self
,
*
args
,
**
kwargs
):
return
super
(
NonAtomicAPIExceptionView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
BasicModel
.
objects
.
create
()
raise
PermissionDenied
self
.
view
=
NonAtomicAPIExceptionView
.
as_view
()
self
.
view
=
NonAtomicAPIExceptionView
.
as_view
()
connections
.
databases
[
'default'
][
'ATOMIC_REQUESTS'
]
=
True
connections
.
databases
[
'default'
][
'ATOMIC_REQUESTS'
]
=
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment