def test_submission_serializer(submission): data = SubmissionSerializer(submission, context={ 'event': submission.event }).data assert set(data.keys()) == { 'code', 'speakers', 'title', 'submission_type', 'state', 'abstract', 'description', 'duration', 'do_not_record', 'content_locale', 'slot', 'image', } assert isinstance(data['speakers'], list) assert data['speakers'][0] == { 'name': submission.speakers.first().name, 'code': submission.speakers.first().code, 'biography': '', # Biography can only be derived from request associated event 'avatar': None, } assert data['submission_type'] == str(submission.submission_type.name) assert data['slot'] is None
def test_submission_serializer(submission, resource): with scope(event=submission.event): data = SubmissionSerializer(submission, context={ 'event': submission.event }).data assert set(data.keys()) == { 'code', 'speakers', 'title', 'submission_type', 'state', 'abstract', 'description', 'duration', 'slot_count', 'do_not_record', 'is_featured', 'content_locale', 'slot', 'image', 'track', 'resources', } assert isinstance(data['speakers'], list) assert data['speakers'] == [] assert data['submission_type'] == str(submission.submission_type.name) assert data['slot'] is None assert data['resources'] == [{ 'resource': resource.resource.url, 'description': resource.description, }]
def test_submission_slot_serializer(slot): with scope(event=slot.submission.event): data = SubmissionSerializer(slot.submission, context={ 'event': slot.submission.event }).data assert set(data.keys()) == { 'code', 'speakers', 'title', 'submission_type', 'state', 'abstract', 'description', 'duration', 'slot_count', 'do_not_record', 'is_featured', 'content_locale', 'slot', 'image', 'track', 'resources', } assert set(data['slot'].keys()) == {'start', 'end', 'room'} assert data['slot']['room'] == slot.room.name
def test_submission_serializer(submission): data = SubmissionSerializer(submission, context={ 'event': submission.event }).data assert set(data.keys()) == { 'code', 'speakers', 'title', 'submission_type', 'state', 'abstract', 'description', 'duration', 'do_not_record', 'content_locale', 'slot', } assert isinstance(data['speakers'], list) assert data['speakers'][0] == { 'name': submission.speakers.first().name, 'code': submission.speakers.first().code, } assert data['submission_type'] == str(submission.submission_type.name) assert data['slot'] is None
def test_submission_serializer_for_organiser(submission, orga_user): class Request: user = orga_user event = submission.event data = SubmissionSerializer(submission, context={'event': submission.event, 'request': Request()}).data assert set(data.keys()) == { 'code', 'speakers', 'title', 'submission_type', 'state', 'abstract', 'description', 'duration', 'slot_count', 'do_not_record', 'is_featured', 'content_locale', 'slot', 'image', 'answers', 'track', } assert isinstance(data['speakers'], list) assert data['speakers'][0] == { 'name': submission.speakers.first().name, 'code': submission.speakers.first().code, 'biography': '', # Biography can only be derived from request associated event 'avatar': None, } assert data['submission_type'] == str(submission.submission_type.name) assert data['slot'] is None
def test_submission_slot_serializer(slot): with scope(event=slot.submission.event): data = SubmissionSerializer(slot.submission, context={ "event": slot.submission.event }).data assert set(data.keys()) == { "code", "speakers", "title", "submission_type", "state", "abstract", "description", "duration", "slot_count", "do_not_record", "is_featured", "content_locale", "slot", "image", "track", "resources", } assert set(data["slot"].keys()) == {"start", "end", "room"} assert data["slot"]["room"] == slot.room.name
def test_submission_serializer(submission, resource): with scope(event=submission.event): data = SubmissionSerializer(submission, context={ "event": submission.event }).data assert set(data.keys()) == { "code", "speakers", "title", "submission_type", "state", "abstract", "description", "duration", "slot_count", "do_not_record", "is_featured", "content_locale", "slot", "image", "track", "resources", } assert isinstance(data["speakers"], list) assert data["speakers"] == [] assert data["submission_type"] == str(submission.submission_type.name) assert data["slot"] is None assert data["resources"] == [{ "resource": resource.resource.url, "description": resource.description, }]
class ReviewSerializer(I18nAwareModelSerializer): submission = SubmissionSerializer() answers = AnswerSerializer(many=True) user = serializers.SlugRelatedField(slug_field='nick', read_only=True) class Meta: model = Review fields = ( 'id', 'submission', 'user', 'text', 'score', 'override_vote', 'created', 'updated', 'answers', )