浏览代码

add created datetime in comment schema

Guénaël Muller 6 年前
父节点
当前提交
b70287437a
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 18 0
      tracim/tests/functional/test_comments.py
  2. 4 0
      tracim/views/core_api/schemas.py

+ 18 - 0
tracim/tests/functional/test_comments.py 查看文件

44
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
44
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
45
         assert comment['author']['avatar_url'] == None
45
         assert comment['author']['avatar_url'] == None
46
         assert comment['author']['public_name'] == 'Bob i.'
46
         assert comment['author']['public_name'] == 'Bob i.'
47
+        # TODO - G.M - 2018-06-179 - better check for datetime
48
+        assert comment['created']
47
 
49
 
48
         comment = res.json_body[2]
50
         comment = res.json_body[2]
49
         assert comment['content_id'] == 20
51
         assert comment['content_id'] == 20
54
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
56
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
55
         assert comment['author']['avatar_url'] == None
57
         assert comment['author']['avatar_url'] == None
56
         assert comment['author']['public_name'] == 'John Reader'
58
         assert comment['author']['public_name'] == 'John Reader'
59
+        # TODO - G.M - 2018-06-179 - better check for datetime
60
+        assert comment['created']
57
 
61
 
58
     def test_api__post_content_comment__ok_200__nominal_case(self) -> None:
62
     def test_api__post_content_comment__ok_200__nominal_case(self) -> None:
59
         """
63
         """
83
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
87
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
84
         assert comment['author']['avatar_url'] is None
88
         assert comment['author']['avatar_url'] is None
85
         assert comment['author']['public_name'] == 'Global manager'
89
         assert comment['author']['public_name'] == 'Global manager'
90
+        # TODO - G.M - 2018-06-179 - better check for datetime
91
+        assert comment['created']
86
 
92
 
87
         res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)  # nopep8
93
         res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)  # nopep8
88
         assert len(res.json_body) == 4
94
         assert len(res.json_body) == 4
110
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
116
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
111
         assert comment['author']['avatar_url'] is None
117
         assert comment['author']['avatar_url'] is None
112
         assert comment['author']['public_name'] == 'Global manager'
118
         assert comment['author']['public_name'] == 'Global manager'
119
+        # TODO - G.M - 2018-06-179 - better check for datetime
120
+        assert comment['created']
113
 
121
 
114
         res = self.testapp.delete(
122
         res = self.testapp.delete(
115
             '/api/v2/workspaces/2/contents/7/comments/18',
123
             '/api/v2/workspaces/2/contents/7/comments/18',
141
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
149
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
142
         assert comment['author']['avatar_url'] is None
150
         assert comment['author']['avatar_url'] is None
143
         assert comment['author']['public_name'] == 'Bob i.'
151
         assert comment['author']['public_name'] == 'Bob i.'
152
+        # TODO - G.M - 2018-06-179 - better check for datetime
153
+        assert comment['created']
144
 
154
 
145
         res = self.testapp.delete(
155
         res = self.testapp.delete(
146
             '/api/v2/workspaces/2/contents/7/comments/19',
156
             '/api/v2/workspaces/2/contents/7/comments/19',
172
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
182
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
173
         assert comment['author']['avatar_url'] is None
183
         assert comment['author']['avatar_url'] is None
174
         assert comment['author']['public_name'] == 'Bob i.'
184
         assert comment['author']['public_name'] == 'Bob i.'
185
+        # TODO - G.M - 2018-06-179 - better check for datetime
186
+        assert comment['created']
175
 
187
 
176
         res = self.testapp.delete(
188
         res = self.testapp.delete(
177
             '/api/v2/workspaces/2/contents/7/comments/19',
189
             '/api/v2/workspaces/2/contents/7/comments/19',
203
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
215
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
204
         assert comment['author']['avatar_url'] is None
216
         assert comment['author']['avatar_url'] is None
205
         assert comment['author']['public_name'] == 'John Reader'
217
         assert comment['author']['public_name'] == 'John Reader'
218
+        # TODO - G.M - 2018-06-179 - better check for datetime
219
+        assert comment['created']
206
 
220
 
207
         res = self.testapp.delete(
221
         res = self.testapp.delete(
208
             '/api/v2/workspaces/2/contents/7/comments/20',
222
             '/api/v2/workspaces/2/contents/7/comments/20',
231
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
245
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
232
         assert comment['author']['avatar_url'] is None
246
         assert comment['author']['avatar_url'] is None
233
         assert comment['author']['public_name'] == 'John Reader'
247
         assert comment['author']['public_name'] == 'John Reader'
248
+        # TODO - G.M - 2018-06-179 - better check for datetime
249
+        assert comment['created']
234
 
250
 
235
         res = self.testapp.delete(
251
         res = self.testapp.delete(
236
             '/api/v2/workspaces/2/contents/7/comments/20',
252
             '/api/v2/workspaces/2/contents/7/comments/20',
259
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
275
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
260
         assert comment['author']['avatar_url'] is None
276
         assert comment['author']['avatar_url'] is None
261
         assert comment['author']['public_name'] == 'John Reader'
277
         assert comment['author']['public_name'] == 'John Reader'
278
+        # TODO - G.M - 2018-06-179 - better check for datetime
279
+        assert comment['created']
262
 
280
 
263
         res = self.testapp.delete(
281
         res = self.testapp.delete(
264
             '/api/v2/workspaces/2/contents/7/comments/20',
282
             '/api/v2/workspaces/2/contents/7/comments/20',

+ 4 - 0
tracim/views/core_api/schemas.py 查看文件

457
         example='<p>This is just an html comment !</p>'
457
         example='<p>This is just an html comment !</p>'
458
     )
458
     )
459
     author = marshmallow.fields.Nested(UserDigestSchema)
459
     author = marshmallow.fields.Nested(UserDigestSchema)
460
+    created = marshmallow.fields.DateTime(
461
+        format='%Y-%m-%dT%H:%M:%SZ',
462
+        description='comment creation date',
463
+    )
460
 
464
 
461
 
465
 
462
 class ContentModifySchema(marshmallow.Schema):
466
 class ContentModifySchema(marshmallow.Schema):