nanterre: do not use transactions for read-only views
This commit is contained in:
parent
3ca520cf2b
commit
6fc83aaaf5
|
@ -15,7 +15,7 @@ from zoo.zoo_nanterre.utils import age_in_years_and_months
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def rsu_schema(db):
|
||||
def rsu_schema(transactional_db):
|
||||
call_command('loaddata', 'rsu')
|
||||
schema = EntitySchema.objects.get(slug='individu')
|
||||
assert schema
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
import datetime
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
|
@ -31,6 +32,7 @@ def test_person_search(db, rsu):
|
|||
assert len(found) == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db(True)
|
||||
def test_create_individu(app, rsu_schema):
|
||||
create_url = reverse('rsu-api-create-individu')
|
||||
response = app.post_json(create_url, {}, status=400)
|
||||
|
|
|
@ -2,6 +2,7 @@ import isodate
|
|||
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db.models.query import Q
|
||||
from django.db.transaction import non_atomic_requests, atomic
|
||||
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
|
@ -96,7 +97,7 @@ class SearchView(APIView):
|
|||
}
|
||||
})
|
||||
|
||||
search = SearchView.as_view()
|
||||
search = non_atomic_requests(SearchView.as_view())
|
||||
|
||||
|
||||
class ReseauView(APIView):
|
||||
|
@ -115,6 +116,7 @@ class ReseauView(APIView):
|
|||
}
|
||||
})
|
||||
|
||||
@atomic
|
||||
def post(self, request, identifier, format=None):
|
||||
qs = Entity.objects.prefetch_related(
|
||||
'left_relations__schema', 'left_relations__right',
|
||||
|
@ -177,7 +179,7 @@ class ReseauView(APIView):
|
|||
'data': individu_to_response(individu),
|
||||
})
|
||||
|
||||
reseau = ReseauView.as_view()
|
||||
reseau = non_atomic_requests(ReseauView.as_view())
|
||||
|
||||
|
||||
class AdresseSerializer(serializers.Serializer):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.views.generic import TemplateView
|
||||
from django.db.transaction import non_atomic_requests
|
||||
|
||||
from . import forms
|
||||
|
||||
|
@ -22,4 +23,4 @@ class Search(TemplateView):
|
|||
return ctx
|
||||
|
||||
|
||||
search = Search.as_view()
|
||||
search = non_atomic_requests(Search.as_view())
|
||||
|
|
Loading…
Reference in New Issue