|
@@ -218,3 +218,219 @@ class TestHtmlDocuments(FunctionalTest):
|
218
|
218
|
assert content['content_type'] == 'page'
|
219
|
219
|
assert content['content_id'] == 6
|
220
|
220
|
assert content['status'] == 'closed-deprecated'
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+class TestThreads(FunctionalTest):
|
|
224
|
+ """
|
|
225
|
+ Tests for /api/v2/workspaces/{workspace_id}/threads/{content_id}
|
|
226
|
+ endpoint
|
|
227
|
+ """
|
|
228
|
+
|
|
229
|
+ fixtures = [BaseFixture, ContentFixtures]
|
|
230
|
+
|
|
231
|
+ def test_api__get_thread__err_400__wrong_content_type(self) -> None:
|
|
232
|
+ """
|
|
233
|
+ Get one html document of a content
|
|
234
|
+ """
|
|
235
|
+ self.testapp.authorization = (
|
|
236
|
+ 'Basic',
|
|
237
|
+ (
|
|
238
|
+ 'admin@admin.admin',
|
|
239
|
+ 'admin@admin.admin'
|
|
240
|
+ )
|
|
241
|
+ )
|
|
242
|
+ res = self.testapp.get(
|
|
243
|
+ '/api/v2/workspaces/2/threads/6',
|
|
244
|
+ status=400
|
|
245
|
+ ) # nopep8
|
|
246
|
+
|
|
247
|
+ def test_api__get_thread__ok_200__nominal_case(self) -> None:
|
|
248
|
+ """
|
|
249
|
+ Get one html document of a content
|
|
250
|
+ """
|
|
251
|
+ self.testapp.authorization = (
|
|
252
|
+ 'Basic',
|
|
253
|
+ (
|
|
254
|
+ 'admin@admin.admin',
|
|
255
|
+ 'admin@admin.admin'
|
|
256
|
+ )
|
|
257
|
+ )
|
|
258
|
+ res = self.testapp.get(
|
|
259
|
+ '/api/v2/workspaces/2/threads/7',
|
|
260
|
+ status=200
|
|
261
|
+ ) # nopep8
|
|
262
|
+ content = res.json_body
|
|
263
|
+ assert content['content_type'] == 'thread'
|
|
264
|
+ assert content['content_id'] == 7
|
|
265
|
+ assert content['is_archived'] is False
|
|
266
|
+ assert content['is_deleted'] is False
|
|
267
|
+ assert content['label'] == 'Best Cakes ?'
|
|
268
|
+ assert content['parent_id'] == 3
|
|
269
|
+ assert content['show_in_ui'] is True
|
|
270
|
+ assert content['slug'] == 'best-cakes'
|
|
271
|
+ assert content['status'] == 'open'
|
|
272
|
+ assert content['workspace_id'] == 2
|
|
273
|
+ assert content['current_revision_id'] == 8
|
|
274
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
275
|
+ assert content['created']
|
|
276
|
+ assert content['author']
|
|
277
|
+ assert content['author']['user_id'] == 1
|
|
278
|
+ assert content['author']['avatar_url'] is None
|
|
279
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
280
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
281
|
+ assert content['modified']
|
|
282
|
+ assert content['last_modifier'] == content['author']
|
|
283
|
+ assert content['raw_content'] == 'What is the best cake ?' # nopep8
|
|
284
|
+
|
|
285
|
+ def test_api__update_thread__ok_200__nominal_case(self) -> None:
|
|
286
|
+ """
|
|
287
|
+ Update(put) one html document of a content
|
|
288
|
+ """
|
|
289
|
+ self.testapp.authorization = (
|
|
290
|
+ 'Basic',
|
|
291
|
+ (
|
|
292
|
+ 'admin@admin.admin',
|
|
293
|
+ 'admin@admin.admin'
|
|
294
|
+ )
|
|
295
|
+ )
|
|
296
|
+ params = {
|
|
297
|
+ 'label': 'My New label',
|
|
298
|
+ 'raw_content': '<p> Le nouveau contenu </p>',
|
|
299
|
+ }
|
|
300
|
+ res = self.testapp.put_json(
|
|
301
|
+ '/api/v2/workspaces/2/threads/7',
|
|
302
|
+ params=params,
|
|
303
|
+ status=200
|
|
304
|
+ )
|
|
305
|
+ content = res.json_body
|
|
306
|
+ assert content['content_type'] == 'thread'
|
|
307
|
+ assert content['content_id'] == 7
|
|
308
|
+ assert content['is_archived'] is False
|
|
309
|
+ assert content['is_deleted'] is False
|
|
310
|
+ assert content['label'] == 'My New label'
|
|
311
|
+ assert content['parent_id'] == 3
|
|
312
|
+ assert content['show_in_ui'] is True
|
|
313
|
+ assert content['slug'] == 'my-new-label'
|
|
314
|
+ assert content['status'] == 'open'
|
|
315
|
+ assert content['workspace_id'] == 2
|
|
316
|
+ assert content['current_revision_id'] == 26
|
|
317
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
318
|
+ assert content['created']
|
|
319
|
+ assert content['author']
|
|
320
|
+ assert content['author']['user_id'] == 1
|
|
321
|
+ assert content['author']['avatar_url'] is None
|
|
322
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
323
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
324
|
+ assert content['modified']
|
|
325
|
+ assert content['last_modifier'] == content['author']
|
|
326
|
+ assert content['raw_content'] == '<p> Le nouveau contenu </p>'
|
|
327
|
+
|
|
328
|
+ res = self.testapp.get(
|
|
329
|
+ '/api/v2/workspaces/2/threads/7',
|
|
330
|
+ status=200
|
|
331
|
+ ) # nopep8
|
|
332
|
+ content = res.json_body
|
|
333
|
+ assert content['content_type'] == 'thread'
|
|
334
|
+ assert content['content_id'] == 7
|
|
335
|
+ assert content['is_archived'] is False
|
|
336
|
+ assert content['is_deleted'] is False
|
|
337
|
+ assert content['label'] == 'My New label'
|
|
338
|
+ assert content['parent_id'] == 3
|
|
339
|
+ assert content['show_in_ui'] is True
|
|
340
|
+ assert content['slug'] == 'my-new-label'
|
|
341
|
+ assert content['status'] == 'open'
|
|
342
|
+ assert content['workspace_id'] == 2
|
|
343
|
+ assert content['current_revision_id'] == 26
|
|
344
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
345
|
+ assert content['created']
|
|
346
|
+ assert content['author']
|
|
347
|
+ assert content['author']['user_id'] == 1
|
|
348
|
+ assert content['author']['avatar_url'] is None
|
|
349
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
350
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
351
|
+ assert content['modified']
|
|
352
|
+ assert content['last_modifier'] == content['author']
|
|
353
|
+ assert content['raw_content'] == '<p> Le nouveau contenu </p>'
|
|
354
|
+
|
|
355
|
+ def test_api__get_thread_revisions__ok_200__nominal_case(
|
|
356
|
+ self
|
|
357
|
+ ) -> None:
|
|
358
|
+ """
|
|
359
|
+ Get one html document of a content
|
|
360
|
+ """
|
|
361
|
+ self.testapp.authorization = (
|
|
362
|
+ 'Basic',
|
|
363
|
+ (
|
|
364
|
+ 'admin@admin.admin',
|
|
365
|
+ 'admin@admin.admin'
|
|
366
|
+ )
|
|
367
|
+ )
|
|
368
|
+ res = self.testapp.get(
|
|
369
|
+ '/api/v2/workspaces/2/threads/7/revisions',
|
|
370
|
+ status=200
|
|
371
|
+ )
|
|
372
|
+ revisions = res.json_body
|
|
373
|
+ assert len(revisions) == 1
|
|
374
|
+ revision = revisions[0]
|
|
375
|
+ assert revision['content_type'] == 'thread'
|
|
376
|
+ assert revision['content_id'] == 7
|
|
377
|
+ assert revision['is_archived'] is False
|
|
378
|
+ assert revision['is_deleted'] is False
|
|
379
|
+ assert revision['label'] == 'Best Cakes ?'
|
|
380
|
+ assert revision['parent_id'] == 3
|
|
381
|
+ assert revision['show_in_ui'] is True
|
|
382
|
+ assert revision['slug'] == 'best-cakes'
|
|
383
|
+ assert revision['status'] == 'open'
|
|
384
|
+ assert revision['workspace_id'] == 2
|
|
385
|
+ assert revision['revision_id'] == 8
|
|
386
|
+ assert revision['sub_content_types']
|
|
387
|
+ # TODO - G.M - 2018-06-173 - Test with real comments
|
|
388
|
+ assert revision['comments_ids'] == []
|
|
389
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
390
|
+ assert revision['created']
|
|
391
|
+ assert revision['author']
|
|
392
|
+ assert revision['author']['user_id'] == 1
|
|
393
|
+ assert revision['author']['avatar_url'] is None
|
|
394
|
+ assert revision['author']['public_name'] == 'Global manager'
|
|
395
|
+
|
|
396
|
+ def test_api__set_thread_status__ok_200__nominal_case(self) -> None:
|
|
397
|
+ """
|
|
398
|
+ Get one html document of a content
|
|
399
|
+ """
|
|
400
|
+ self.testapp.authorization = (
|
|
401
|
+ 'Basic',
|
|
402
|
+ (
|
|
403
|
+ 'admin@admin.admin',
|
|
404
|
+ 'admin@admin.admin'
|
|
405
|
+ )
|
|
406
|
+ )
|
|
407
|
+ params = {
|
|
408
|
+ 'status': 'closed-deprecated',
|
|
409
|
+ }
|
|
410
|
+
|
|
411
|
+ # before
|
|
412
|
+ res = self.testapp.get(
|
|
413
|
+ '/api/v2/workspaces/2/threads/7',
|
|
414
|
+ status=200
|
|
415
|
+ ) # nopep8
|
|
416
|
+ content = res.json_body
|
|
417
|
+ assert content['content_type'] == 'thread'
|
|
418
|
+ assert content['content_id'] == 7
|
|
419
|
+ assert content['status'] == 'open'
|
|
420
|
+
|
|
421
|
+ # set status
|
|
422
|
+ res = self.testapp.put_json(
|
|
423
|
+ '/api/v2/workspaces/2/threads/7/status',
|
|
424
|
+ params=params,
|
|
425
|
+ status=204
|
|
426
|
+ )
|
|
427
|
+
|
|
428
|
+ # after
|
|
429
|
+ res = self.testapp.get(
|
|
430
|
+ '/api/v2/workspaces/2/threads/7',
|
|
431
|
+ status=200
|
|
432
|
+ ) # nopep8
|
|
433
|
+ content = res.json_body
|
|
434
|
+ assert content['content_type'] == 'thread'
|
|
435
|
+ assert content['content_id'] == 7
|
|
436
|
+ assert content['status'] == 'closed-deprecated'
|