|
@@ -50,10 +50,10 @@ class TestCommentsEndpoint(FunctionalTest):
|
50
|
50
|
assert comment['parent_id'] == 7
|
51
|
51
|
assert comment['raw_content'] == '<p>You are right, but Kouign-amann are clearly better.</p>' # nopep8
|
52
|
52
|
assert comment['author']
|
53
|
|
- assert comment['author']['user_id'] == 1
|
|
53
|
+ assert comment['author']['user_id'] == 4
|
54
|
54
|
# TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
55
|
55
|
assert comment['author']['avatar_url'] == None
|
56
|
|
- assert comment['author']['public_name'] == 'Global manager'
|
|
56
|
+ assert comment['author']['public_name'] == 'John Reader'
|
57
|
57
|
|
58
|
58
|
def test_api__post_content_comment__ok_200__nominal_case(self) -> None:
|
59
|
59
|
"""
|
|
@@ -88,9 +88,9 @@ class TestCommentsEndpoint(FunctionalTest):
|
88
|
88
|
assert len(res.json_body) == 4
|
89
|
89
|
assert comment == res.json_body[3]
|
90
|
90
|
|
91
|
|
- def test_api__delete_content_comment__ok_200__nominal_case(self) -> None:
|
|
91
|
+ def test_api__delete_content_comment__ok_200__workspace_manager_owner(self) -> None:
|
92
|
92
|
"""
|
93
|
|
- Get alls comments of a content
|
|
93
|
+ delete comment (user is workspace_manager and owner)
|
94
|
94
|
"""
|
95
|
95
|
self.testapp.authorization = (
|
96
|
96
|
'Basic',
|
|
@@ -101,10 +101,10 @@ class TestCommentsEndpoint(FunctionalTest):
|
101
|
101
|
)
|
102
|
102
|
res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
103
|
103
|
assert len(res.json_body) == 3
|
104
|
|
- comment = res.json_body[2]
|
105
|
|
- assert comment['content_id'] == 20
|
|
104
|
+ comment = res.json_body[0]
|
|
105
|
+ assert comment['content_id'] == 18
|
106
|
106
|
assert comment['parent_id'] == 7
|
107
|
|
- assert comment['raw_content'] == '<p>You are right, but Kouign-amann are clearly better.</p>' # nopep8
|
|
107
|
+ assert comment['raw_content'] == '<p> What is for you the best cake ever ? </br> I personnally vote for Chocolate cupcake !</p>' # nopep8
|
108
|
108
|
assert comment['author']
|
109
|
109
|
assert comment['author']['user_id'] == 1
|
110
|
110
|
# TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
@@ -112,9 +112,155 @@ class TestCommentsEndpoint(FunctionalTest):
|
112
|
112
|
assert comment['author']['public_name'] == 'Global manager'
|
113
|
113
|
|
114
|
114
|
res = self.testapp.delete(
|
115
|
|
- '/api/v2/workspaces/2/contents/7/comments/20',
|
|
115
|
+ '/api/v2/workspaces/2/contents/7/comments/18',
|
|
116
|
+ status=204
|
|
117
|
+ )
|
|
118
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
119
|
+ assert len(res.json_body) == 2
|
|
120
|
+ assert not [content for content in res.json_body if content['content_id'] == 18] # nopep8
|
|
121
|
+
|
|
122
|
+ def test_api__delete_content_comment__ok_200__workspace_manager(self) -> None:
|
|
123
|
+ """
|
|
124
|
+ delete comment (user is workspace_manager)
|
|
125
|
+ """
|
|
126
|
+ self.testapp.authorization = (
|
|
127
|
+ 'Basic',
|
|
128
|
+ (
|
|
129
|
+ 'admin@admin.admin',
|
|
130
|
+ 'admin@admin.admin'
|
|
131
|
+ )
|
|
132
|
+ )
|
|
133
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
134
|
+ assert len(res.json_body) == 3
|
|
135
|
+ comment = res.json_body[1]
|
|
136
|
+ assert comment['content_id'] == 19
|
|
137
|
+ assert comment['parent_id'] == 7
|
|
138
|
+ assert comment['raw_content'] == '<p>What about Apple Pie ? There are Awesome !</p>' # nopep8
|
|
139
|
+ assert comment['author']
|
|
140
|
+ assert comment['author']['user_id'] == 3
|
|
141
|
+ # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
142
|
+ assert comment['author']['avatar_url'] is None
|
|
143
|
+ assert comment['author']['public_name'] == 'Bob i.'
|
|
144
|
+
|
|
145
|
+ res = self.testapp.delete(
|
|
146
|
+ '/api/v2/workspaces/2/contents/7/comments/19',
|
116
|
147
|
status=204
|
117
|
148
|
)
|
118
|
149
|
res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
119
|
150
|
assert len(res.json_body) == 2
|
120
|
|
- assert not [content for content in res.json_body if content['content_id'] == 20] # nopep8
|
|
151
|
+ assert not [content for content in res.json_body if content['content_id'] == 19] # nopep8
|
|
152
|
+
|
|
153
|
+ def test_api__delete_content_comment__ok_200__content_manager_owner(self) -> None:
|
|
154
|
+ """
|
|
155
|
+ delete comment (user is content-manager and owner)
|
|
156
|
+ """
|
|
157
|
+ self.testapp.authorization = (
|
|
158
|
+ 'Basic',
|
|
159
|
+ (
|
|
160
|
+ 'admin@admin.admin',
|
|
161
|
+ 'admin@admin.admin'
|
|
162
|
+ )
|
|
163
|
+ )
|
|
164
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
165
|
+ assert len(res.json_body) == 3
|
|
166
|
+ comment = res.json_body[1]
|
|
167
|
+ assert comment['content_id'] == 19
|
|
168
|
+ assert comment['parent_id'] == 7
|
|
169
|
+ assert comment['raw_content'] == '<p>What about Apple Pie ? There are Awesome !</p>' # nopep8
|
|
170
|
+ assert comment['author']
|
|
171
|
+ assert comment['author']['user_id'] == 3
|
|
172
|
+ # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
173
|
+ assert comment['author']['avatar_url'] is None
|
|
174
|
+ assert comment['author']['public_name'] == 'Bob i.'
|
|
175
|
+
|
|
176
|
+ res = self.testapp.delete(
|
|
177
|
+ '/api/v2/workspaces/2/contents/7/comments/19',
|
|
178
|
+ status=204
|
|
179
|
+ )
|
|
180
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
181
|
+ assert len(res.json_body) == 2
|
|
182
|
+ assert not [content for content in res.json_body if content['content_id'] == 19] # nopep8
|
|
183
|
+
|
|
184
|
+ def test_api__delete_content_comment__err_403__content_manager(self) -> None:
|
|
185
|
+ """
|
|
186
|
+ delete comment (user is content-manager)
|
|
187
|
+ """
|
|
188
|
+ self.testapp.authorization = (
|
|
189
|
+ 'Basic',
|
|
190
|
+ (
|
|
191
|
+ 'bob@fsf.local',
|
|
192
|
+ 'foobarbaz'
|
|
193
|
+ )
|
|
194
|
+ )
|
|
195
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
196
|
+ assert len(res.json_body) == 3
|
|
197
|
+ comment = res.json_body[2]
|
|
198
|
+ assert comment['content_id'] == 20
|
|
199
|
+ assert comment['parent_id'] == 7
|
|
200
|
+ assert comment['raw_content'] == '<p>You are right, but Kouign-amann are clearly better.</p>' # nopep8
|
|
201
|
+ assert comment['author']
|
|
202
|
+ assert comment['author']['user_id'] == 4
|
|
203
|
+ # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
204
|
+ assert comment['author']['avatar_url'] is None
|
|
205
|
+ assert comment['author']['public_name'] == 'John Reader'
|
|
206
|
+
|
|
207
|
+ res = self.testapp.delete(
|
|
208
|
+ '/api/v2/workspaces/2/contents/7/comments/20',
|
|
209
|
+ status=403
|
|
210
|
+ )
|
|
211
|
+
|
|
212
|
+ def test_api__delete_content_comment__err_403__reader_owner(self) -> None:
|
|
213
|
+ """
|
|
214
|
+ delete comment (user is reader and owner)
|
|
215
|
+ """
|
|
216
|
+ self.testapp.authorization = (
|
|
217
|
+ 'Basic',
|
|
218
|
+ (
|
|
219
|
+ 'bob@fsf.local',
|
|
220
|
+ 'foobarbaz'
|
|
221
|
+ )
|
|
222
|
+ )
|
|
223
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
224
|
+ assert len(res.json_body) == 3
|
|
225
|
+ comment = res.json_body[2]
|
|
226
|
+ assert comment['content_id'] == 20
|
|
227
|
+ assert comment['parent_id'] == 7
|
|
228
|
+ assert comment['raw_content'] == '<p>You are right, but Kouign-amann are clearly better.</p>' # nopep8
|
|
229
|
+ assert comment['author']
|
|
230
|
+ assert comment['author']['user_id'] == 4
|
|
231
|
+ # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
232
|
+ assert comment['author']['avatar_url'] is None
|
|
233
|
+ assert comment['author']['public_name'] == 'John Reader'
|
|
234
|
+
|
|
235
|
+ res = self.testapp.delete(
|
|
236
|
+ '/api/v2/workspaces/2/contents/7/comments/20',
|
|
237
|
+ status=403
|
|
238
|
+ )
|
|
239
|
+
|
|
240
|
+ def test_api__delete_content_comment__err_403__reader(self) -> None:
|
|
241
|
+ """
|
|
242
|
+ delete comment (user is reader)
|
|
243
|
+ """
|
|
244
|
+ self.testapp.authorization = (
|
|
245
|
+ 'Basic',
|
|
246
|
+ (
|
|
247
|
+ 'bob@fsf.local',
|
|
248
|
+ 'foobarbaz'
|
|
249
|
+ )
|
|
250
|
+ )
|
|
251
|
+ res = self.testapp.get('/api/v2/workspaces/2/contents/7/comments', status=200)
|
|
252
|
+ assert len(res.json_body) == 3
|
|
253
|
+ comment = res.json_body[2]
|
|
254
|
+ assert comment['content_id'] == 20
|
|
255
|
+ assert comment['parent_id'] == 7
|
|
256
|
+ assert comment['raw_content'] == '<p>You are right, but Kouign-amann are clearly better.</p>' # nopep8
|
|
257
|
+ assert comment['author']
|
|
258
|
+ assert comment['author']['user_id'] == 4
|
|
259
|
+ # TODO - G.M - 2018-06-172 - [avatar] setup avatar url
|
|
260
|
+ assert comment['author']['avatar_url'] is None
|
|
261
|
+ assert comment['author']['public_name'] == 'John Reader'
|
|
262
|
+
|
|
263
|
+ res = self.testapp.delete(
|
|
264
|
+ '/api/v2/workspaces/2/contents/7/comments/20',
|
|
265
|
+ status=403
|
|
266
|
+ )
|