things moved or modified
This commit is contained in:
parent
c9cdc67b4f
commit
541939ea17
3 changed files with 19 additions and 8 deletions
|
@ -46,16 +46,17 @@ class EventSpecificSerializerMixin():
|
|||
|
||||
# Serializers
|
||||
# TODO rajouter des permissions
|
||||
class PlaceSerializer(serializers.ModelSerializer,
|
||||
EventSpecificSerializerMixin):
|
||||
class PlaceSerializer(EventSpecificSerializerMixin,
|
||||
serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Place
|
||||
fields = ('url', 'id', 'name', 'description', 'event')
|
||||
|
||||
|
||||
# TODO rajouter des permissions
|
||||
class ActivityTagSerializer(serializers.ModelSerializer,
|
||||
EventSpecificSerializerMixin):
|
||||
class ActivityTagSerializer(EventSpecificSerializerMixin,
|
||||
serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ActivityTag
|
||||
fields = ('url', 'id', 'name', 'is_public', 'color', 'event')
|
||||
|
|
|
@ -5,7 +5,7 @@ from rest_framework.test import APITestCase
|
|||
from event.models import Event, Place, ActivityTag, ActivityTemplate
|
||||
|
||||
from api.event.serializers import ActivityTemplateSerializer, EventSerializer
|
||||
from api.test_mixins import EventBasedModelTestMixin, EventSpecificTestMixin,\
|
||||
from api.testcases import EventBasedModelTestMixin, EventSpecificTestMixin,\
|
||||
ModelTestMixin
|
||||
|
||||
User = get_user_model()
|
|
@ -54,8 +54,15 @@ class DataBaseMixin(object):
|
|||
|
||||
class EventBasedModelTestMixin(DataBaseMixin):
|
||||
"""
|
||||
Note : need to define : `model`, `base_name`, `initial_count`,
|
||||
`data_creation`, `instance_name`, `field_tested`, `serializer`
|
||||
Note : need to define :
|
||||
`model`: the model served by the API
|
||||
`base_name`: the base_name used in the URL
|
||||
`initial_count`: (will disappear) inital count in the db
|
||||
`data_creation`: name in db used to create new instance
|
||||
`instance_name`: existing instance name in the db
|
||||
used for update/delete
|
||||
`field_tested`: name of field tested in the update test
|
||||
`serializer`: serialiser used for the API
|
||||
|
||||
tests for models served by the API that are related to an event
|
||||
and whose API urls are nested under ../event/<event_id>/%model
|
||||
|
@ -152,7 +159,10 @@ class EventSpecificTestMixin(object):
|
|||
"""
|
||||
Tests is the EventSpecifics querysets are rendered correctly
|
||||
using the API
|
||||
Note : need to define : `model`, `root_base_name` and `event_base_name`
|
||||
Note : need to define :
|
||||
`model`: the concerned model serve by the API
|
||||
`root_base_name`: the base_name used in the root-level urls
|
||||
`event_base_name`: the base_name used in the event-level urls
|
||||
|
||||
tests for models served by the API that inherit EventSpecificMixin
|
||||
"""
|
Loading…
Reference in a new issue