|
@@ -1,4 +1,12 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+import transaction
|
|
3
|
+from depot.io.utils import FileIntent
|
|
4
|
+
|
|
5
|
+from tracim import models
|
|
6
|
+from tracim.lib.core.content import ContentApi
|
|
7
|
+from tracim.lib.core.workspace import WorkspaceApi
|
|
8
|
+from tracim.models.data import ContentType
|
|
9
|
+from tracim.models import get_tm_session
|
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
|
|
@@ -429,6 +437,513 @@ class TestHtmlDocuments(FunctionalTest):
|
429
|
437
|
)
|
430
|
438
|
|
431
|
439
|
|
|
440
|
+class TestFiles(FunctionalTest):
|
|
441
|
+ """
|
|
442
|
+ Tests for /api/v2/workspaces/{workspace_id}/files/{content_id}
|
|
443
|
+ endpoint
|
|
444
|
+ """
|
|
445
|
+
|
|
446
|
+ fixtures = [BaseFixture, ContentFixtures]
|
|
447
|
+
|
|
448
|
+ def test_api__get_file__ok_200__nominal_case(self) -> None:
|
|
449
|
+ """
|
|
450
|
+ Get one file of a content
|
|
451
|
+ """
|
|
452
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
453
|
+ admin = dbsession.query(models.User) \
|
|
454
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
455
|
+ .one()
|
|
456
|
+ workspace_api = WorkspaceApi(
|
|
457
|
+ current_user=admin,
|
|
458
|
+ session=dbsession,
|
|
459
|
+ config=self.app_config
|
|
460
|
+ )
|
|
461
|
+ content_api = ContentApi(
|
|
462
|
+ current_user=admin,
|
|
463
|
+ session=dbsession,
|
|
464
|
+ config=self.app_config
|
|
465
|
+ )
|
|
466
|
+ business_workspace = workspace_api.get_one(1)
|
|
467
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
468
|
+ test_file = content_api.create(
|
|
469
|
+ content_type=ContentType.File,
|
|
470
|
+ workspace=business_workspace,
|
|
471
|
+ parent=tool_folder,
|
|
472
|
+ label='Test file',
|
|
473
|
+ do_save=False,
|
|
474
|
+ do_notify=False,
|
|
475
|
+ )
|
|
476
|
+ test_file.file_extension = '.txt'
|
|
477
|
+ test_file.depot_file = FileIntent(
|
|
478
|
+ b'Test file',
|
|
479
|
+ 'Test_file.txt',
|
|
480
|
+ 'text/plain',
|
|
481
|
+ )
|
|
482
|
+ content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8
|
|
483
|
+ dbsession.flush()
|
|
484
|
+ transaction.commit()
|
|
485
|
+
|
|
486
|
+ self.testapp.authorization = (
|
|
487
|
+ 'Basic',
|
|
488
|
+ (
|
|
489
|
+ 'admin@admin.admin',
|
|
490
|
+ 'admin@admin.admin'
|
|
491
|
+ )
|
|
492
|
+ )
|
|
493
|
+ res = self.testapp.get(
|
|
494
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
495
|
+ status=200
|
|
496
|
+ )
|
|
497
|
+ content = res.json_body
|
|
498
|
+ assert content['content_type'] == 'file'
|
|
499
|
+ assert content['content_id'] == test_file.content_id
|
|
500
|
+ assert content['is_archived'] is False
|
|
501
|
+ assert content['is_deleted'] is False
|
|
502
|
+ assert content['label'] == 'Test_file'
|
|
503
|
+ assert content['parent_id'] == 1
|
|
504
|
+ assert content['show_in_ui'] is True
|
|
505
|
+ assert content['slug'] == 'test-file'
|
|
506
|
+ assert content['status'] == 'open'
|
|
507
|
+ assert content['workspace_id'] == 1
|
|
508
|
+ assert content['current_revision_id']
|
|
509
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
510
|
+ assert content['created']
|
|
511
|
+ assert content['author']
|
|
512
|
+ assert content['author']['user_id'] == 1
|
|
513
|
+ assert content['author']['avatar_url'] is None
|
|
514
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
515
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
516
|
+ assert content['modified']
|
|
517
|
+ assert content['last_modifier'] == content['author']
|
|
518
|
+ assert content['raw_content'] == '<p>description</p>' # nopep8
|
|
519
|
+
|
|
520
|
+ def test_api__get_files__err_400__wrong_content_type(self) -> None:
|
|
521
|
+ """
|
|
522
|
+ Get one file of a content content
|
|
523
|
+ """
|
|
524
|
+ self.testapp.authorization = (
|
|
525
|
+ 'Basic',
|
|
526
|
+ (
|
|
527
|
+ 'admin@admin.admin',
|
|
528
|
+ 'admin@admin.admin'
|
|
529
|
+ )
|
|
530
|
+ )
|
|
531
|
+ res = self.testapp.get(
|
|
532
|
+ '/api/v2/workspaces/2/files/6',
|
|
533
|
+ status=400
|
|
534
|
+ )
|
|
535
|
+
|
|
536
|
+ def test_api__get_file__err_400__content_does_not_exist(self) -> None: # nopep8
|
|
537
|
+ """
|
|
538
|
+ Get one file (content 170 does not exist in db
|
|
539
|
+ """
|
|
540
|
+ self.testapp.authorization = (
|
|
541
|
+ 'Basic',
|
|
542
|
+ (
|
|
543
|
+ 'admin@admin.admin',
|
|
544
|
+ 'admin@admin.admin'
|
|
545
|
+ )
|
|
546
|
+ )
|
|
547
|
+ res = self.testapp.get(
|
|
548
|
+ '/api/v2/workspaces/1/files/170',
|
|
549
|
+ status=400
|
|
550
|
+ )
|
|
551
|
+
|
|
552
|
+ def test_api__get_file__err_400__content_not_in_workspace(self) -> None: # nopep8
|
|
553
|
+ """
|
|
554
|
+ Get one file (content 9 is in workspace 2)
|
|
555
|
+ """
|
|
556
|
+ self.testapp.authorization = (
|
|
557
|
+ 'Basic',
|
|
558
|
+ (
|
|
559
|
+ 'admin@admin.admin',
|
|
560
|
+ 'admin@admin.admin'
|
|
561
|
+ )
|
|
562
|
+ )
|
|
563
|
+ res = self.testapp.get(
|
|
564
|
+ '/api/v2/workspaces/1/files/9',
|
|
565
|
+ status=400
|
|
566
|
+ )
|
|
567
|
+
|
|
568
|
+ def test_api__get_file__err_400__workspace_does_not_exist(self) -> None: # nopep8
|
|
569
|
+ """
|
|
570
|
+ Get one file (Workspace 40 does not exist)
|
|
571
|
+ """
|
|
572
|
+ self.testapp.authorization = (
|
|
573
|
+ 'Basic',
|
|
574
|
+ (
|
|
575
|
+ 'admin@admin.admin',
|
|
576
|
+ 'admin@admin.admin'
|
|
577
|
+ )
|
|
578
|
+ )
|
|
579
|
+ res = self.testapp.get(
|
|
580
|
+ '/api/v2/workspaces/40/files/9',
|
|
581
|
+ status=400
|
|
582
|
+ )
|
|
583
|
+
|
|
584
|
+ def test_api__get_file__err_400__workspace_id_is_not_int(self) -> None: # nopep8
|
|
585
|
+ """
|
|
586
|
+ Get one file, workspace id is not int
|
|
587
|
+ """
|
|
588
|
+ self.testapp.authorization = (
|
|
589
|
+ 'Basic',
|
|
590
|
+ (
|
|
591
|
+ 'admin@admin.admin',
|
|
592
|
+ 'admin@admin.admin'
|
|
593
|
+ )
|
|
594
|
+ )
|
|
595
|
+ res = self.testapp.get(
|
|
596
|
+ '/api/v2/workspaces/coucou/files/9',
|
|
597
|
+ status=400
|
|
598
|
+ )
|
|
599
|
+
|
|
600
|
+ def test_api__get_file__err_400__content_id_is_not_int(self) -> None: # nopep8
|
|
601
|
+ """
|
|
602
|
+ Get one file, content_id is not int
|
|
603
|
+ """
|
|
604
|
+ self.testapp.authorization = (
|
|
605
|
+ 'Basic',
|
|
606
|
+ (
|
|
607
|
+ 'admin@admin.admin',
|
|
608
|
+ 'admin@admin.admin'
|
|
609
|
+ )
|
|
610
|
+ )
|
|
611
|
+ res = self.testapp.get(
|
|
612
|
+ '/api/v2/workspaces/2/files/coucou',
|
|
613
|
+ status=400
|
|
614
|
+ )
|
|
615
|
+
|
|
616
|
+ def test_api__update_file_info_err_400__empty_label(self) -> None: # nopep8
|
|
617
|
+ """
|
|
618
|
+ Update(put) one file
|
|
619
|
+ """
|
|
620
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
621
|
+ admin = dbsession.query(models.User) \
|
|
622
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
623
|
+ .one()
|
|
624
|
+ workspace_api = WorkspaceApi(
|
|
625
|
+ current_user=admin,
|
|
626
|
+ session=dbsession,
|
|
627
|
+ config=self.app_config
|
|
628
|
+ )
|
|
629
|
+ content_api = ContentApi(
|
|
630
|
+ current_user=admin,
|
|
631
|
+ session=dbsession,
|
|
632
|
+ config=self.app_config
|
|
633
|
+ )
|
|
634
|
+ business_workspace = workspace_api.get_one(1)
|
|
635
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
636
|
+ test_file = content_api.create(
|
|
637
|
+ content_type=ContentType.File,
|
|
638
|
+ workspace=business_workspace,
|
|
639
|
+ parent=tool_folder,
|
|
640
|
+ label='Test file',
|
|
641
|
+ do_save=False,
|
|
642
|
+ do_notify=False,
|
|
643
|
+ )
|
|
644
|
+ test_file.file_extension = '.txt'
|
|
645
|
+ test_file.depot_file = FileIntent(
|
|
646
|
+ b'Test file',
|
|
647
|
+ 'Test_file.txt',
|
|
648
|
+ 'text/plain',
|
|
649
|
+ )
|
|
650
|
+ content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8
|
|
651
|
+ dbsession.flush()
|
|
652
|
+ transaction.commit()
|
|
653
|
+
|
|
654
|
+ self.testapp.authorization = (
|
|
655
|
+ 'Basic',
|
|
656
|
+ (
|
|
657
|
+ 'admin@admin.admin',
|
|
658
|
+ 'admin@admin.admin'
|
|
659
|
+ )
|
|
660
|
+ )
|
|
661
|
+ params = {
|
|
662
|
+ 'label': '',
|
|
663
|
+ 'raw_content': '<p> Le nouveau contenu </p>',
|
|
664
|
+ }
|
|
665
|
+ res = self.testapp.put_json(
|
|
666
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
667
|
+ params=params,
|
|
668
|
+ status=400
|
|
669
|
+ )
|
|
670
|
+
|
|
671
|
+ def test_api__update_file_info__ok_200__nominal_case(self) -> None:
|
|
672
|
+ """
|
|
673
|
+ Update(put) one file
|
|
674
|
+ """
|
|
675
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
676
|
+ admin = dbsession.query(models.User) \
|
|
677
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
678
|
+ .one()
|
|
679
|
+ workspace_api = WorkspaceApi(
|
|
680
|
+ current_user=admin,
|
|
681
|
+ session=dbsession,
|
|
682
|
+ config=self.app_config
|
|
683
|
+ )
|
|
684
|
+ content_api = ContentApi(
|
|
685
|
+ current_user=admin,
|
|
686
|
+ session=dbsession,
|
|
687
|
+ config=self.app_config
|
|
688
|
+ )
|
|
689
|
+ business_workspace = workspace_api.get_one(1)
|
|
690
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
691
|
+ test_file = content_api.create(
|
|
692
|
+ content_type=ContentType.File,
|
|
693
|
+ workspace=business_workspace,
|
|
694
|
+ parent=tool_folder,
|
|
695
|
+ label='Test file',
|
|
696
|
+ do_save=False,
|
|
697
|
+ do_notify=False,
|
|
698
|
+ )
|
|
699
|
+ test_file.file_extension = '.txt'
|
|
700
|
+ test_file.depot_file = FileIntent(
|
|
701
|
+ b'Test file',
|
|
702
|
+ 'Test_file.txt',
|
|
703
|
+ 'text/plain',
|
|
704
|
+ )
|
|
705
|
+ content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8
|
|
706
|
+ dbsession.flush()
|
|
707
|
+ transaction.commit()
|
|
708
|
+
|
|
709
|
+ self.testapp.authorization = (
|
|
710
|
+ 'Basic',
|
|
711
|
+ (
|
|
712
|
+ 'admin@admin.admin',
|
|
713
|
+ 'admin@admin.admin'
|
|
714
|
+ )
|
|
715
|
+ )
|
|
716
|
+ params = {
|
|
717
|
+ 'label': 'My New label',
|
|
718
|
+ 'raw_content': '<p> Le nouveau contenu </p>',
|
|
719
|
+ }
|
|
720
|
+ res = self.testapp.put_json(
|
|
721
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
722
|
+ params=params,
|
|
723
|
+ status=200
|
|
724
|
+ )
|
|
725
|
+ content = res.json_body
|
|
726
|
+ assert content['content_type'] == 'file'
|
|
727
|
+ assert content['content_id'] == test_file.content_id
|
|
728
|
+ assert content['is_archived'] is False
|
|
729
|
+ assert content['is_deleted'] is False
|
|
730
|
+ assert content['label'] == 'My New label'
|
|
731
|
+ assert content['parent_id'] == 1
|
|
732
|
+ assert content['show_in_ui'] is True
|
|
733
|
+ assert content['slug'] == 'my-new-label'
|
|
734
|
+ assert content['status'] == 'open'
|
|
735
|
+ assert content['workspace_id'] == 1
|
|
736
|
+ assert content['current_revision_id']
|
|
737
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
738
|
+ assert content['created']
|
|
739
|
+ assert content['author']
|
|
740
|
+ assert content['author']['user_id'] == 1
|
|
741
|
+ assert content['author']['avatar_url'] is None
|
|
742
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
743
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
744
|
+ assert content['modified']
|
|
745
|
+ assert content['last_modifier'] == content['author']
|
|
746
|
+ assert content['raw_content'] == '<p> Le nouveau contenu </p>'
|
|
747
|
+
|
|
748
|
+ res = self.testapp.get(
|
|
749
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
750
|
+ status=200
|
|
751
|
+ )
|
|
752
|
+ content = res.json_body
|
|
753
|
+ assert content['content_type'] == 'file'
|
|
754
|
+ assert content['content_id'] == test_file.content_id
|
|
755
|
+ assert content['is_archived'] is False
|
|
756
|
+ assert content['is_deleted'] is False
|
|
757
|
+ assert content['label'] == 'My New label'
|
|
758
|
+ assert content['parent_id'] == 1
|
|
759
|
+ assert content['show_in_ui'] is True
|
|
760
|
+ assert content['slug'] == 'my-new-label'
|
|
761
|
+ assert content['status'] == 'open'
|
|
762
|
+ assert content['workspace_id'] == 1
|
|
763
|
+ assert content['current_revision_id']
|
|
764
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
765
|
+ assert content['created']
|
|
766
|
+ assert content['author']
|
|
767
|
+ assert content['author']['user_id'] == 1
|
|
768
|
+ assert content['author']['avatar_url'] is None
|
|
769
|
+ assert content['author']['public_name'] == 'Global manager'
|
|
770
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
771
|
+ assert content['modified']
|
|
772
|
+ assert content['last_modifier'] == content['author']
|
|
773
|
+ assert content['raw_content'] == '<p> Le nouveau contenu </p>'
|
|
774
|
+
|
|
775
|
+ def test_api__get_file_revisions__ok_200__nominal_case(
|
|
776
|
+ self
|
|
777
|
+ ) -> None:
|
|
778
|
+ """
|
|
779
|
+ Get file revisions
|
|
780
|
+ """
|
|
781
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
782
|
+ admin = dbsession.query(models.User) \
|
|
783
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
784
|
+ .one()
|
|
785
|
+ workspace_api = WorkspaceApi(
|
|
786
|
+ current_user=admin,
|
|
787
|
+ session=dbsession,
|
|
788
|
+ config=self.app_config
|
|
789
|
+ )
|
|
790
|
+ content_api = ContentApi(
|
|
791
|
+ current_user=admin,
|
|
792
|
+ session=dbsession,
|
|
793
|
+ config=self.app_config
|
|
794
|
+ )
|
|
795
|
+ business_workspace = workspace_api.get_one(1)
|
|
796
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
797
|
+ test_file = content_api.create(
|
|
798
|
+ content_type=ContentType.File,
|
|
799
|
+ workspace=business_workspace,
|
|
800
|
+ parent=tool_folder,
|
|
801
|
+ label='Test file',
|
|
802
|
+ do_save=False,
|
|
803
|
+ do_notify=False,
|
|
804
|
+ )
|
|
805
|
+ test_file.file_extension = '.txt'
|
|
806
|
+ test_file.depot_file = FileIntent(
|
|
807
|
+ b'Test file',
|
|
808
|
+ 'Test_file.txt',
|
|
809
|
+ 'text/plain',
|
|
810
|
+ )
|
|
811
|
+ content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8
|
|
812
|
+ dbsession.flush()
|
|
813
|
+ transaction.commit()
|
|
814
|
+
|
|
815
|
+ self.testapp.authorization = (
|
|
816
|
+ 'Basic',
|
|
817
|
+ (
|
|
818
|
+ 'admin@admin.admin',
|
|
819
|
+ 'admin@admin.admin'
|
|
820
|
+ )
|
|
821
|
+ )
|
|
822
|
+ res = self.testapp.get(
|
|
823
|
+ '/api/v2/workspaces/1/files/{}/revisions'.format(test_file.content_id),
|
|
824
|
+ status=200
|
|
825
|
+ )
|
|
826
|
+ revisions = res.json_body
|
|
827
|
+ assert len(revisions) == 1
|
|
828
|
+ revision = revisions[0]
|
|
829
|
+ assert revision['content_type'] == 'file'
|
|
830
|
+ assert revision['content_id'] == test_file.content_id
|
|
831
|
+ assert revision['is_archived'] is False
|
|
832
|
+ assert revision['is_deleted'] is False
|
|
833
|
+ assert revision['label'] == 'Test_file'
|
|
834
|
+ assert revision['parent_id'] == 1
|
|
835
|
+ assert revision['show_in_ui'] is True
|
|
836
|
+ assert revision['slug'] == 'test-file'
|
|
837
|
+ assert revision['status'] == 'open'
|
|
838
|
+ assert revision['workspace_id'] == 1
|
|
839
|
+ assert revision['revision_id']
|
|
840
|
+ assert revision['sub_content_types']
|
|
841
|
+ # TODO - G.M - 2018-06-173 - Test with real comments
|
|
842
|
+ assert revision['comment_ids'] == []
|
|
843
|
+ # TODO - G.M - 2018-06-173 - check date format
|
|
844
|
+ assert revision['created']
|
|
845
|
+ assert revision['author']
|
|
846
|
+ assert revision['author']['user_id'] == 1
|
|
847
|
+ assert revision['author']['avatar_url'] is None
|
|
848
|
+ assert revision['author']['public_name'] == 'Global manager'
|
|
849
|
+
|
|
850
|
+ def test_api__set_file_status__ok_200__nominal_case(self) -> None:
|
|
851
|
+ """
|
|
852
|
+ set file status
|
|
853
|
+ """
|
|
854
|
+ dbsession = get_tm_session(self.session_factory, transaction.manager)
|
|
855
|
+ admin = dbsession.query(models.User) \
|
|
856
|
+ .filter(models.User.email == 'admin@admin.admin') \
|
|
857
|
+ .one()
|
|
858
|
+ workspace_api = WorkspaceApi(
|
|
859
|
+ current_user=admin,
|
|
860
|
+ session=dbsession,
|
|
861
|
+ config=self.app_config
|
|
862
|
+ )
|
|
863
|
+ content_api = ContentApi(
|
|
864
|
+ current_user=admin,
|
|
865
|
+ session=dbsession,
|
|
866
|
+ config=self.app_config
|
|
867
|
+ )
|
|
868
|
+ business_workspace = workspace_api.get_one(1)
|
|
869
|
+ tool_folder = content_api.get_one(1, content_type=ContentType.Any)
|
|
870
|
+ test_file = content_api.create(
|
|
871
|
+ content_type=ContentType.File,
|
|
872
|
+ workspace=business_workspace,
|
|
873
|
+ parent=tool_folder,
|
|
874
|
+ label='Test file',
|
|
875
|
+ do_save=False,
|
|
876
|
+ do_notify=False,
|
|
877
|
+ )
|
|
878
|
+ test_file.file_extension = '.txt'
|
|
879
|
+ test_file.depot_file = FileIntent(
|
|
880
|
+ b'Test file',
|
|
881
|
+ 'Test_file.txt',
|
|
882
|
+ 'text/plain',
|
|
883
|
+ )
|
|
884
|
+ content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8
|
|
885
|
+ dbsession.flush()
|
|
886
|
+ transaction.commit()
|
|
887
|
+
|
|
888
|
+ self.testapp.authorization = (
|
|
889
|
+ 'Basic',
|
|
890
|
+ (
|
|
891
|
+ 'admin@admin.admin',
|
|
892
|
+ 'admin@admin.admin'
|
|
893
|
+ )
|
|
894
|
+ )
|
|
895
|
+ params = {
|
|
896
|
+ 'status': 'closed-deprecated',
|
|
897
|
+ }
|
|
898
|
+
|
|
899
|
+ # before
|
|
900
|
+ res = self.testapp.get(
|
|
901
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
902
|
+ status=200
|
|
903
|
+ )
|
|
904
|
+ content = res.json_body
|
|
905
|
+ assert content['content_type'] == 'file'
|
|
906
|
+ assert content['content_id'] == test_file.content_id
|
|
907
|
+ assert content['status'] == 'open'
|
|
908
|
+
|
|
909
|
+ # set status
|
|
910
|
+ res = self.testapp.put_json(
|
|
911
|
+ '/api/v2/workspaces/1/files/{}/status'.format(test_file.content_id),
|
|
912
|
+ params=params,
|
|
913
|
+ status=204
|
|
914
|
+ )
|
|
915
|
+
|
|
916
|
+ # after
|
|
917
|
+ res = self.testapp.get(
|
|
918
|
+ '/api/v2/workspaces/1/files/{}'.format(test_file.content_id),
|
|
919
|
+ status=200
|
|
920
|
+ )
|
|
921
|
+ content = res.json_body
|
|
922
|
+ assert content['content_type'] == 'file'
|
|
923
|
+ assert content['content_id'] == test_file.content_id
|
|
924
|
+ assert content['status'] == 'closed-deprecated'
|
|
925
|
+
|
|
926
|
+ def test_api__set_file_status__err_400__wrong_status(self) -> None:
|
|
927
|
+ """
|
|
928
|
+ set file status
|
|
929
|
+ """
|
|
930
|
+ self.testapp.authorization = (
|
|
931
|
+ 'Basic',
|
|
932
|
+ (
|
|
933
|
+ 'admin@admin.admin',
|
|
934
|
+ 'admin@admin.admin'
|
|
935
|
+ )
|
|
936
|
+ )
|
|
937
|
+ params = {
|
|
938
|
+ 'status': 'unexistant-status',
|
|
939
|
+ }
|
|
940
|
+ res = self.testapp.put_json(
|
|
941
|
+ '/api/v2/workspaces/2/files/6/status',
|
|
942
|
+ params=params,
|
|
943
|
+ status=400
|
|
944
|
+ )
|
|
945
|
+
|
|
946
|
+
|
432
|
947
|
class TestThreads(FunctionalTest):
|
433
|
948
|
"""
|
434
|
949
|
Tests for /api/v2/workspaces/{workspace_id}/threads/{content_id}
|