@@ 591-668 (lines=78) @@ | ||
588 | assert res[0]['content_id'] == firstly_created_but_recently_updated.content_id |
|
589 | assert res[1]['content_id'] == secondly_created_but_not_updated.content_id |
|
590 | ||
591 | def test_api__get_recently_active_content__err__400__bad_before_content_id(self): # nopep8 |
|
592 | # TODO - G.M - 2018-07-20 - Better fix for this test, do not use sleep() |
|
593 | # anymore to fix datetime lack of precision. |
|
594 | ||
595 | # init DB |
|
596 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
597 | admin = dbsession.query(models.User) \ |
|
598 | .filter(models.User.email == '[email protected]') \ |
|
599 | .one() |
|
600 | workspace_api = WorkspaceApi( |
|
601 | current_user=admin, |
|
602 | session=dbsession, |
|
603 | config=self.app_config |
|
604 | ||
605 | ) |
|
606 | workspace = WorkspaceApi( |
|
607 | current_user=admin, |
|
608 | session=dbsession, |
|
609 | config=self.app_config, |
|
610 | ).create_workspace( |
|
611 | 'test workspace', |
|
612 | save_now=True |
|
613 | ) |
|
614 | workspace2 = WorkspaceApi( |
|
615 | current_user=admin, |
|
616 | session=dbsession, |
|
617 | config=self.app_config, |
|
618 | ).create_workspace( |
|
619 | 'test workspace2', |
|
620 | save_now=True |
|
621 | ) |
|
622 | ||
623 | api = ContentApi( |
|
624 | current_user=admin, |
|
625 | session=dbsession, |
|
626 | config=self.app_config, |
|
627 | ) |
|
628 | main_folder_workspace2 = api.create(content_type_list.Folder.slug, workspace2, None, 'Hepla', '', True) # nopep8 |
|
629 | main_folder = api.create(content_type_list.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
630 | # creation order test |
|
631 | firstly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
632 | secondly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'another creation_order_test', '', True) # nopep8 |
|
633 | # update order test |
|
634 | firstly_created_but_recently_updated = api.create(content_type_list.Page.slug, workspace, main_folder, 'update_order_test', '', True) # nopep8 |
|
635 | secondly_created_but_not_updated = api.create(content_type_list.Page.slug, workspace, main_folder, 'another update_order_test', '', True) # nopep8 |
|
636 | with new_revision( |
|
637 | session=dbsession, |
|
638 | tm=transaction.manager, |
|
639 | content=firstly_created_but_recently_updated, |
|
640 | ): |
|
641 | firstly_created_but_recently_updated.description = 'Just an update' |
|
642 | api.save(firstly_created_but_recently_updated) |
|
643 | # comment change order |
|
644 | firstly_created_but_recently_commented = api.create(content_type_list.Page.slug, workspace, main_folder, 'this is randomized label content', '', True) # nopep8 |
|
645 | secondly_created_but_not_commented = api.create(content_type_list.Page.slug, workspace, main_folder, 'this is another randomized label content', '', True) # nopep8 |
|
646 | comments = api.create_comment(workspace, firstly_created_but_recently_commented, 'juste a super comment', True) # nopep8 |
|
647 | content_workspace_2 = api.create(content_type_list.Page.slug, workspace2, main_folder_workspace2, 'content_workspace_2', '', True) # nopep8 |
|
648 | dbsession.flush() |
|
649 | transaction.commit() |
|
650 | ||
651 | self.testapp.authorization = ( |
|
652 | 'Basic', |
|
653 | ( |
|
654 | '[email protected]', |
|
655 | '[email protected]' |
|
656 | ) |
|
657 | ) |
|
658 | params = { |
|
659 | 'before_content_id': 4000 |
|
660 | } |
|
661 | res = self.testapp.get( |
|
662 | '/api/v2/users/1/workspaces/{}/contents/recently_active'.format(workspace.workspace_id), # nopep8 |
|
663 | status=400, |
|
664 | params=params |
|
665 | ) |
|
666 | assert isinstance(res.json, dict) |
|
667 | assert 'code' in res.json.keys() |
|
668 | assert res.json_body['code'] == error.CONTENT_NOT_FOUND |
|
669 | ||
670 | ||
671 | class TestUserReadStatusEndpoint(FunctionalTest): |
@@ 272-349 (lines=78) @@ | ||
269 | assert res[0]['content_id'] == firstly_created_but_recently_updated.content_id |
|
270 | assert res[1]['content_id'] == secondly_created_but_not_updated.content_id |
|
271 | ||
272 | def test_api__get_recently_active_content__err__400__bad_before_content_id(self): # nopep8 |
|
273 | # TODO - G.M - 2018-07-20 - Better fix for this test, do not use sleep() |
|
274 | # anymore to fix datetime lack of precision. |
|
275 | ||
276 | # init DB |
|
277 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
278 | admin = dbsession.query(models.User) \ |
|
279 | .filter(models.User.email == '[email protected]') \ |
|
280 | .one() |
|
281 | workspace_api = WorkspaceApi( |
|
282 | current_user=admin, |
|
283 | session=dbsession, |
|
284 | config=self.app_config |
|
285 | ||
286 | ) |
|
287 | workspace = WorkspaceApi( |
|
288 | current_user=admin, |
|
289 | session=dbsession, |
|
290 | config=self.app_config, |
|
291 | ).create_workspace( |
|
292 | 'test workspace', |
|
293 | save_now=True |
|
294 | ) |
|
295 | workspace2 = WorkspaceApi( |
|
296 | current_user=admin, |
|
297 | session=dbsession, |
|
298 | config=self.app_config, |
|
299 | ).create_workspace( |
|
300 | 'test workspace2', |
|
301 | save_now=True |
|
302 | ) |
|
303 | ||
304 | api = ContentApi( |
|
305 | current_user=admin, |
|
306 | session=dbsession, |
|
307 | config=self.app_config, |
|
308 | ) |
|
309 | main_folder_workspace2 = api.create(content_type_list.Folder.slug, workspace2, None, 'Hepla', '', True) # nopep8 |
|
310 | main_folder = api.create(content_type_list.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8 |
|
311 | # creation order test |
|
312 | firstly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'creation_order_test', '', True) # nopep8 |
|
313 | secondly_created = api.create(content_type_list.Page.slug, workspace, main_folder, 'another creation_order_test', '', True) # nopep8 |
|
314 | # update order test |
|
315 | firstly_created_but_recently_updated = api.create(content_type_list.Page.slug, workspace, main_folder, 'update_order_test', '', True) # nopep8 |
|
316 | secondly_created_but_not_updated = api.create(content_type_list.Page.slug, workspace, main_folder, 'another update_order_test', '', True) # nopep8 |
|
317 | with new_revision( |
|
318 | session=dbsession, |
|
319 | tm=transaction.manager, |
|
320 | content=firstly_created_but_recently_updated, |
|
321 | ): |
|
322 | firstly_created_but_recently_updated.description = 'Just an update' |
|
323 | api.save(firstly_created_but_recently_updated) |
|
324 | # comment change order |
|
325 | firstly_created_but_recently_commented = api.create(content_type_list.Page.slug, workspace, main_folder, 'this is randomized label content', '', True) # nopep8 |
|
326 | secondly_created_but_not_commented = api.create(content_type_list.Page.slug, workspace, main_folder, 'this is another randomized label content', '', True) # nopep8 |
|
327 | comments = api.create_comment(workspace, firstly_created_but_recently_commented, 'juste a super comment', True) # nopep8 |
|
328 | content_workspace_2 = api.create(content_type_list.Page.slug, workspace2, main_folder_workspace2, 'content_workspace_2', '', True) # nopep8 |
|
329 | dbsession.flush() |
|
330 | transaction.commit() |
|
331 | ||
332 | self.testapp.authorization = ( |
|
333 | 'Basic', |
|
334 | ( |
|
335 | '[email protected]', |
|
336 | '[email protected]' |
|
337 | ) |
|
338 | ) |
|
339 | params = { |
|
340 | 'before_content_id': 4000 |
|
341 | } |
|
342 | res = self.testapp.get( |
|
343 | '/api/v2/users/me/workspaces/{}/contents/recently_active'.format(workspace.workspace_id), # nopep8 |
|
344 | status=400, |
|
345 | params=params |
|
346 | ) |
|
347 | assert isinstance(res.json, dict) |
|
348 | assert 'code' in res.json.keys() |
|
349 | assert res.json_body['code'] == error.CONTENT_NOT_FOUND |
|
350 | ||
351 | ||
352 | class TestUserReadStatusEndpoint(FunctionalTest): |