Browse Source

add created datetime in comment schema

Guénaël Muller 6 years ago
parent
commit
b70287437a
2 changed files with 22 additions and 0 deletions
  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 View File

@@ -44,6 +44,8 @@ class TestCommentsEndpoint(FunctionalTest):
44 44
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
45 45
         assert comment['author']['avatar_url'] == None
46 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 50
         comment = res.json_body[2]
49 51
         assert comment['content_id'] == 20
@@ -54,6 +56,8 @@ class TestCommentsEndpoint(FunctionalTest):
54 56
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
55 57
         assert comment['author']['avatar_url'] == None
56 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 62
     def test_api__post_content_comment__ok_200__nominal_case(self) -> None:
59 63
         """
@@ -83,6 +87,8 @@ class TestCommentsEndpoint(FunctionalTest):
83 87
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
84 88
         assert comment['author']['avatar_url'] is None
85 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 93
         res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)  # nopep8
88 94
         assert len(res.json_body) == 4
@@ -110,6 +116,8 @@ class TestCommentsEndpoint(FunctionalTest):
110 116
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
111 117
         assert comment['author']['avatar_url'] is None
112 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 122
         res = self.testapp.delete(
115 123
             '/api/v2/workspaces/2/contents/7/comments/18',
@@ -141,6 +149,8 @@ class TestCommentsEndpoint(FunctionalTest):
141 149
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
142 150
         assert comment['author']['avatar_url'] is None
143 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 155
         res = self.testapp.delete(
146 156
             '/api/v2/workspaces/2/contents/7/comments/19',
@@ -172,6 +182,8 @@ class TestCommentsEndpoint(FunctionalTest):
172 182
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
173 183
         assert comment['author']['avatar_url'] is None
174 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 188
         res = self.testapp.delete(
177 189
             '/api/v2/workspaces/2/contents/7/comments/19',
@@ -203,6 +215,8 @@ class TestCommentsEndpoint(FunctionalTest):
203 215
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
204 216
         assert comment['author']['avatar_url'] is None
205 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 221
         res = self.testapp.delete(
208 222
             '/api/v2/workspaces/2/contents/7/comments/20',
@@ -231,6 +245,8 @@ class TestCommentsEndpoint(FunctionalTest):
231 245
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
232 246
         assert comment['author']['avatar_url'] is None
233 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 251
         res = self.testapp.delete(
236 252
             '/api/v2/workspaces/2/contents/7/comments/20',
@@ -259,6 +275,8 @@ class TestCommentsEndpoint(FunctionalTest):
259 275
         # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
260 276
         assert comment['author']['avatar_url'] is None
261 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 281
         res = self.testapp.delete(
264 282
             '/api/v2/workspaces/2/contents/7/comments/20',

+ 4 - 0
tracim/views/core_api/schemas.py View File

@@ -457,6 +457,10 @@ class CommentSchema(marshmallow.Schema):
457 457
         example='<p>This is just an html comment !</p>'
458 458
     )
459 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 466
 class ContentModifySchema(marshmallow.Schema):