|
@@ -1,4 +1,12 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+import transaction
|
|
3
|
+
|
|
4
|
+from tracim import models
|
|
5
|
+from tracim.lib.core.content import ContentApi
|
|
6
|
+from tracim.lib.core.workspace import WorkspaceApi
|
|
7
|
+from tracim.models import get_tm_session
|
|
8
|
+from tracim.models.contents import ContentTypeLegacy as ContentType
|
|
9
|
+from tracim.models.revision_protection import new_revision
|
2
|
10
|
from tracim.tests import FunctionalTest
|
3
|
11
|
from tracim.tests import set_html_document_slug_to_legacy
|
4
|
12
|
from tracim.fixtures.content import Content as ContentFixtures
|
|
@@ -730,6 +738,106 @@ class TestThreads(FunctionalTest):
|
730
|
738
|
assert revision['author']['avatar_url'] is None
|
731
|
739
|
assert revision['author']['public_name'] == 'Bob i.'
|
732
|
740
|
|
|
741
|
+ def test_api__get_thread_revisions__ok_200__most_revision_type(self) -> None:
|
|
742
|
+ """
|
|
743
|
+ get threads revisions
|
|
744
|
+ """
|
|
745
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
746
|
+ admin = dbsession.query(models.User) \
|
|
747
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
748
|
+ .one()
|
|
749
|
+ workspace_api = WorkspaceApi(
|
|
750
|
+ current_user=admin,
|
|
751
|
+ session=dbsession,
|
|
752
|
+ config=self.app_config
|
|
753
|
+ )
|
|
754
|
+ business_workspace = workspace_api.get_one(1)
|
|
755
|
+ content_api = ContentApi(
|
|
756
|
+ current_user=admin,
|
|
757
|
+ session=dbsession,
|
|
758
|
+ config=self.app_config
|
|
759
|
+ )
|
|
760
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
761
|
+ test_thread = content_api.create(
|
|
762
|
+ content_type=ContentType.Thread,
|
|
763
|
+ workspace=business_workspace,
|
|
764
|
+ parent=tool_folder,
|
|
765
|
+ label='Test Thread',
|
|
766
|
+ do_save=True,
|
|
767
|
+ do_notify=False,
|
|
768
|
+ )
|
|
769
|
+ with new_revision(
|
|
770
|
+ session=dbsession,
|
|
771
|
+ tm=transaction.manager,
|
|
772
|
+ content=test_thread,
|
|
773
|
+ ):
|
|
774
|
+ content_api.update_content(
|
|
775
|
+ test_thread,
|
|
776
|
+ new_label='test_thread_updated',
|
|
777
|
+ new_content='Just a test'
|
|
778
|
+ )
|
|
779
|
+ content_api.save(test_thread)
|
|
780
|
+ with new_revision(
|
|
781
|
+ session=dbsession,
|
|
782
|
+ tm=transaction.manager,
|
|
783
|
+ content=test_thread,
|
|
784
|
+ ):
|
|
785
|
+ content_api.archive(test_thread)
|
|
786
|
+ content_api.save(test_thread)
|
|
787
|
+
|
|
788
|
+ with new_revision(
|
|
789
|
+ session=dbsession,
|
|
790
|
+ tm=transaction.manager,
|
|
791
|
+ content=test_thread,
|
|
792
|
+ ):
|
|
793
|
+ content_api.unarchive(test_thread)
|
|
794
|
+ content_api.save(test_thread)
|
|
795
|
+
|
|
796
|
+ with new_revision(
|
|
797
|
+ session=dbsession,
|
|
798
|
+ tm=transaction.manager,
|
|
799
|
+ content=test_thread,
|
|
800
|
+ ):
|
|
801
|
+ content_api.delete(test_thread)
|
|
802
|
+ content_api.save(test_thread)
|
|
803
|
+
|
|
804
|
+ with new_revision(
|
|
805
|
+ session=dbsession,
|
|
806
|
+ tm=transaction.manager,
|
|
807
|
+ content=test_thread,
|
|
808
|
+ ):
|
|
809
|
+ content_api.undelete(test_thread)
|
|
810
|
+ content_api.save(test_thread)
|
|
811
|
+ dbsession.flush()
|
|
812
|
+ transaction.commit()
|
|
813
|
+ self.testapp.authorization = (
|
|
814
|
+ 'Basic',
|
|
815
|
+ (
|
|
816
|
+ 'admin@admin.admin',
|
|
817
|
+ 'admin@admin.admin'
|
|
818
|
+ )
|
|
819
|
+ )
|
|
820
|
+ res = self.testapp.get(
|
|
821
|
+ '/api/v2/workspaces/1/threads/{}/revisions'.format(test_thread.content_id), # nopep8
|
|
822
|
+ status=200
|
|
823
|
+ )
|
|
824
|
+ revisions = res.json_body
|
|
825
|
+ assert len(revisions) == 6
|
|
826
|
+ for revision in revisions:
|
|
827
|
+ revision['content_type'] == 'thread'
|
|
828
|
+ revision['workspace_id'] == 1
|
|
829
|
+ revision['content_id'] == test_thread.content_id
|
|
830
|
+ revision = revisions[0]
|
|
831
|
+ revision['revision_type'] == 'creation'
|
|
832
|
+ revision = revisions[1]
|
|
833
|
+ revision['revision_type'] == 'archiving'
|
|
834
|
+ revision = revisions[2]
|
|
835
|
+ revision['revision_type'] == 'unarchiving'
|
|
836
|
+ revision = revisions[3]
|
|
837
|
+ revision['revision_type'] == 'deletion'
|
|
838
|
+ revision = revisions[4]
|
|
839
|
+ revision['revision_type'] == 'undeletion'
|
|
840
|
+
|
733
|
841
|
def test_api__set_thread_status__ok_200__nominal_case(self) -> None:
|
734
|
842
|
"""
|
735
|
843
|
Set thread status
|