mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
API: adhere to Bugsink's DB-transactional model
as per https://www.bugsink.com/blog/database-transactions/
This commit is contained in:
@@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404
|
||||
from rest_framework import viewsets
|
||||
|
||||
from bugsink.api_pagination import AscDescCursorPagination
|
||||
from bugsink.api_mixins import ExpandViewSetMixin
|
||||
from bugsink.api_mixins import ExpandViewSetMixin, AtomicRequestMixin
|
||||
|
||||
from .models import Project
|
||||
from .serializers import (
|
||||
@@ -20,7 +20,7 @@ class ProjectPagination(AscDescCursorPagination):
|
||||
default_direction = "asc"
|
||||
|
||||
|
||||
class ProjectViewSet(ExpandViewSetMixin, viewsets.ModelViewSet):
|
||||
class ProjectViewSet(AtomicRequestMixin, ExpandViewSetMixin, viewsets.ModelViewSet):
|
||||
"""
|
||||
/api/canonical/0/projects/
|
||||
GET /projects/ → list ordered by name ASC, hides soft-deleted, optional ?team=<uuid> filter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.test import TestCase as DjangoTestCase
|
||||
from bugsink.test_utils import TransactionTestCase25251 as TransactionTestCase
|
||||
from django.urls import reverse
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
@@ -7,7 +7,7 @@ from teams.models import Team
|
||||
from projects.models import Project
|
||||
|
||||
|
||||
class ProjectApiTests(DjangoTestCase):
|
||||
class ProjectApiTests(TransactionTestCase):
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
token = AuthToken.objects.create()
|
||||
@@ -77,7 +77,7 @@ class ProjectApiTests(DjangoTestCase):
|
||||
self.assertEqual(r.status_code, 405)
|
||||
|
||||
|
||||
class ExpansionTests(DjangoTestCase):
|
||||
class ExpansionTests(TransactionTestCase):
|
||||
"""
|
||||
Expansion tests are exercised via ProjectViewSet, but the intent is to validate the
|
||||
generic ExpandableSerializerMixin infrastructure.
|
||||
|
||||
Reference in New Issue
Block a user