|
@@ -242,7 +242,9 @@ class TestUserRecentlyActiveContentEndpoint(FunctionalTest):
|
242
|
242
|
|
243
|
243
|
|
244
|
244
|
class TestUserReadStatusEndpoint(FunctionalTest):
|
245
|
|
-
|
|
245
|
+ """
|
|
246
|
+ Tests for /api/v2/users/{user_id}/workspaces/{workspace_id}/contents/read_status # nopep8
|
|
247
|
+ """
|
246
|
248
|
def test_api__get_read_status__ok__200__all(self):
|
247
|
249
|
|
248
|
250
|
# init DB
|
|
@@ -434,7 +436,9 @@ class TestUserReadStatusEndpoint(FunctionalTest):
|
434
|
436
|
|
435
|
437
|
|
436
|
438
|
class TestUserSetContentAsRead(FunctionalTest):
|
437
|
|
-
|
|
439
|
+ """
|
|
440
|
+ Tests for /api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/read # nopep8
|
|
441
|
+ """
|
438
|
442
|
def test_api_set_content_as_read__ok__200__nominal_case(self):
|
439
|
443
|
# init DB
|
440
|
444
|
dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
@@ -488,13 +492,69 @@ class TestUserSetContentAsRead(FunctionalTest):
|
488
|
492
|
assert res.json_body[0]['content_id'] == firstly_created.content_id
|
489
|
493
|
assert res.json_body[0]['read_by_user'] is True
|
490
|
494
|
|
491
|
|
- @pytest.mark.xfail(reason='To be done')
|
492
|
495
|
def test_api_set_content_as_read__ok__200__with_comments(self):
|
493
|
|
- raise NotImplemented()
|
|
496
|
+ # init DB
|
|
497
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
498
|
+ admin = dbsession.query(models.User) \
|
|
499
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
500
|
+ .one()
|
|
501
|
+ workspace_api = WorkspaceApi(
|
|
502
|
+ current_user=admin,
|
|
503
|
+ session=dbsession,
|
|
504
|
+ config=self.app_config
|
494
|
505
|
|
|
506
|
+ )
|
|
507
|
+ workspace = WorkspaceApi(
|
|
508
|
+ current_user=admin,
|
|
509
|
+ session=dbsession,
|
|
510
|
+ config=self.app_config,
|
|
511
|
+ ).create_workspace(
|
|
512
|
+ 'test workspace',
|
|
513
|
+ save_now=True
|
|
514
|
+ )
|
|
515
|
+ api = ContentApi(
|
|
516
|
+ current_user=admin,
|
|
517
|
+ session=dbsession,
|
|
518
|
+ config=self.app_config,
|
|
519
|
+ )
|
|
520
|
+ main_folder = api.create(ContentType.Folder, workspace, None, 'this is randomized folder', '', True) # nopep8
|
|
521
|
+ # creation order test
|
|
522
|
+ firstly_created = api.create(ContentType.Page, workspace, main_folder, 'creation_order_test', '', True) # nopep8
|
|
523
|
+ comments = api.create_comment(workspace, firstly_created, 'juste a super comment', True) # nopep8
|
|
524
|
+ api.mark_unread(firstly_created)
|
|
525
|
+ api.mark_unread(comments)
|
|
526
|
+ dbsession.flush()
|
|
527
|
+ transaction.commit()
|
495
|
528
|
|
496
|
|
-class TestUserSetContentAsUnread(FunctionalTest):
|
|
529
|
+ self.testapp.authorization = (
|
|
530
|
+ 'Basic',
|
|
531
|
+ (
|
|
532
|
+ 'admin@admin.admin',
|
|
533
|
+ 'admin@admin.admin'
|
|
534
|
+ )
|
|
535
|
+ )
|
|
536
|
+ res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8
|
|
537
|
+ assert res.json_body[0]['content_id'] == firstly_created.content_id
|
|
538
|
+ assert res.json_body[0]['read_by_user'] is False
|
|
539
|
+ self.testapp.put(
|
|
540
|
+ '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/read'.format( # nopep8
|
|
541
|
+ workspace_id=workspace.workspace_id,
|
|
542
|
+ content_id=firstly_created.content_id,
|
|
543
|
+ user_id=admin.user_id,
|
|
544
|
+ )
|
|
545
|
+ )
|
|
546
|
+ res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8
|
|
547
|
+ assert res.json_body[0]['content_id'] == firstly_created.content_id
|
|
548
|
+ assert res.json_body[0]['read_by_user'] is True
|
497
|
549
|
|
|
550
|
+ # comment is also set as read
|
|
551
|
+ assert comments.has_new_information_for(admin) is False
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+class TestUserSetContentAsUnread(FunctionalTest):
|
|
555
|
+ """
|
|
556
|
+ Tests for /api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/unread # nopep8
|
|
557
|
+ """
|
498
|
558
|
def test_api_set_content_as_unread__ok__200__nominal_case(self):
|
499
|
559
|
# init DB
|
500
|
560
|
dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
@@ -548,12 +608,68 @@ class TestUserSetContentAsUnread(FunctionalTest):
|
548
|
608
|
assert res.json_body[0]['content_id'] == firstly_created.content_id
|
549
|
609
|
assert res.json_body[0]['read_by_user'] is False
|
550
|
610
|
|
551
|
|
- @pytest.mark.xfail(reason='To be done')
|
552
|
611
|
def test_api_set_content_as_unread__ok__200__with_comments(self):
|
553
|
|
- raise NotImplemented()
|
|
612
|
+ # init DB
|
|
613
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
614
|
+ admin = dbsession.query(models.User) \
|
|
615
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
616
|
+ .one()
|
|
617
|
+ workspace_api = WorkspaceApi(
|
|
618
|
+ current_user=admin,
|
|
619
|
+ session=dbsession,
|
|
620
|
+ config=self.app_config
|
554
|
621
|
|
555
|
|
-class TestUserSetWorkspaceAsRead(FunctionalTest):
|
|
622
|
+ )
|
|
623
|
+ workspace = WorkspaceApi(
|
|
624
|
+ current_user=admin,
|
|
625
|
+ session=dbsession,
|
|
626
|
+ config=self.app_config,
|
|
627
|
+ ).create_workspace(
|
|
628
|
+ 'test workspace',
|
|
629
|
+ save_now=True
|
|
630
|
+ )
|
|
631
|
+ api = ContentApi(
|
|
632
|
+ current_user=admin,
|
|
633
|
+ session=dbsession,
|
|
634
|
+ config=self.app_config,
|
|
635
|
+ )
|
|
636
|
+ main_folder = api.create(ContentType.Folder, workspace, None, 'this is randomized folder', '', True) # nopep8
|
|
637
|
+ # creation order test
|
|
638
|
+ firstly_created = api.create(ContentType.Page, workspace, main_folder, 'creation_order_test', '', True) # nopep8
|
|
639
|
+ comments = api.create_comment(workspace, firstly_created, 'juste a super comment', True) # nopep8
|
|
640
|
+ api.mark_read(firstly_created)
|
|
641
|
+ api.mark_read(comments)
|
|
642
|
+ dbsession.flush()
|
|
643
|
+ transaction.commit()
|
556
|
644
|
|
|
645
|
+ self.testapp.authorization = (
|
|
646
|
+ 'Basic',
|
|
647
|
+ (
|
|
648
|
+ 'admin@admin.admin',
|
|
649
|
+ 'admin@admin.admin'
|
|
650
|
+ )
|
|
651
|
+ )
|
|
652
|
+ res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8
|
|
653
|
+ assert res.json_body[0]['content_id'] == firstly_created.content_id
|
|
654
|
+ assert res.json_body[0]['read_by_user'] is True
|
|
655
|
+ self.testapp.put(
|
|
656
|
+ '/api/v2/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}/unread'.format( # nopep8
|
|
657
|
+ workspace_id=workspace.workspace_id,
|
|
658
|
+ content_id=firstly_created.content_id,
|
|
659
|
+ user_id=admin.user_id,
|
|
660
|
+ )
|
|
661
|
+ )
|
|
662
|
+ res = self.testapp.get('/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id), status=200) # nopep8
|
|
663
|
+ assert res.json_body[0]['content_id'] == firstly_created.content_id
|
|
664
|
+ assert res.json_body[0]['read_by_user'] is False
|
|
665
|
+
|
|
666
|
+ assert comments.has_new_information_for(admin) is True
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+class TestUserSetWorkspaceAsRead(FunctionalTest):
|
|
670
|
+ """
|
|
671
|
+ Tests for /api/v2/users/{user_id}/workspaces/{workspace_id}/read
|
|
672
|
+ """
|
557
|
673
|
def test_api_set_content_as_read__ok__200__nominal_case(self):
|
558
|
674
|
# init DB
|
559
|
675
|
dbsession = get_tm_session(self.session_factory, transaction.manager)
|