Coverage for src/dto/user_dto.py : 100%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from flask_restx import Namespace, fields
3from .base import UserBaseObj, GroupBaseObj, UserItemObj, UserExportObj, messageObj, paginationObj, GenreBaseObj, MetaUserContentBaseObj
6class UserDto:
7 api = Namespace("user", description="User related operations.")
9 # Objects
10 api.models[GenreBaseObj.name] = GenreBaseObj
11 genre_base = GenreBaseObj
13 api.models[MetaUserContentBaseObj.name] = MetaUserContentBaseObj
14 meta_user_content_base = MetaUserContentBaseObj
16 api.models[UserBaseObj.name] = UserBaseObj
17 user_base = UserBaseObj
19 api.models[UserItemObj.name] = UserItemObj
20 user_item = UserItemObj
22 api.models[UserExportObj.name] = UserExportObj
23 user_full_obj = UserExportObj
25 # Responses
26 data_resp = api.clone(
27 "User Data Response",
28 messageObj,
29 {
30 "user": fields.Nested(user_item)
31 }
32 )
34 export_user_resp = api.clone(
35 "User Exportation Data Response",
36 messageObj,
37 {
38 "user": fields.Nested(user_full_obj)
39 }
40 )
42 search_data_resp = api.clone(
43 "User Research Data Response",
44 paginationObj,
45 {
46 "content": fields.List(fields.Nested(user_base))
47 }
48 )
49 genres_resp = api.clone(
50 "Content genres Data Response",
51 messageObj,
52 {
53 "content": fields.List(fields.Nested(genre_base))
54 }
55 )
57 meta_resp = api.clone(
58 "MetaUserContent Data Response",
59 messageObj,
60 {
61 "content": fields.Nested(meta_user_content_base)
62 }
63 )
65 # Expected data
66 user_data = api.model(
67 "UserDataExpected",
68 {
69 "username": fields.String(min=4, max=15),
70 "password": fields.String(min=8, max=128),
71 "email": fields.String(min=5, max=64)
72 },
73 )
75 bad_recommendation = api.model(
76 "ApplicationMetaExpected",
77 {
78 "reason_categorie": fields.List(fields.String),
79 "reason": fields.List(fields.String)
80 }
81 )
82 content_meta = api.model(
83 "ContentMetaExpected",
84 {
85 "additional_count": fields.Float(min=0.0),
86 "rating": fields.Integer(min=0, max=5),
87 }
88 )