Coverage for demo_server/api/blog/serializers.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 15:44 +0000

1# Copyright (c) Microsoft Corporation. 

2# Licensed under the MIT License. 

3 

4from flask_restplus import fields 1a

5from demo_server.api.restplus import api 1a

6 

7 

8blog_post_public = api.model('Blog post public', { 1a

9 'id': fields.Integer(readOnly=True, 

10 description='The unique identifier of a blog post'), 

11 'body': fields.String(required=True, description='Article content'), 

12}) 

13 

14blog_post = api.model('Blog post', { 1a

15 'id': fields.Integer(readOnly=True, 

16 description='The unique identifier of a blog post'), 

17 'checksum': fields.String(required=False, 

18 description='The sha1 checksum of the body'), 

19 'body': fields.String(required=True, description='Article content'), 

20}) 

21 

22pagination = api.model('A page of results', { 1a

23 'per_page': fields.Integer(description='Number of items per page of results'), 

24 'page': fields.Integer(description='Number of this page of results'), 

25 'total': fields.Integer(description='Total number of results'), 

26}) 

27 

28page_of_blog_posts = api.inherit('Page of blog posts', pagination, { 1a

29 'items': fields.List(fields.Nested(blog_post_public)) 

30}) 

31 

32category = api.model('Blog category', { 1a

33 'id': fields.Integer(readOnly=True, description='The unique identifier of a blog category'), 

34 'name': fields.String(required=True, description='Category name'), 

35}) 

36 

37category_with_posts = api.inherit('Blog category with posts', category, { 1a

38 'posts': fields.List(fields.Nested(blog_post)) 

39})