Code Duplication    Length = 46-47 lines in 3 locations

backend/tracim_backend/tests/functional/test_workspaces.py 3 locations

@@ 3781-3827 (lines=47) @@
3778
        assert 'code' in res.json.keys()
3779
        assert res.json_body['code'] == error.PARENT_NOT_FOUND  # nopep8
3780
3781
    def test_api__post_content_create_generic_content__ok_200__in_folder(self) -> None:  # nopep8
3782
        """
3783
        Create generic content in folder
3784
        """
3785
        self.testapp.authorization = (
3786
            'Basic',
3787
            (
3788
                '[email protected]',
3789
                '[email protected]'
3790
            )
3791
        )
3792
        params = {
3793
            'label': 'GenericCreatedContent',
3794
            'content_type': 'html-document',
3795
            'parent_id': 10,
3796
        }
3797
        res = self.testapp.post_json(
3798
            '/api/v2/workspaces/1/contents',
3799
            params=params,
3800
            status=200
3801
        )
3802
        assert res
3803
        assert res.json_body
3804
        assert res.json_body['status'] == 'open'
3805
        assert res.json_body['content_id']
3806
        assert res.json_body['content_type'] == 'html-document'
3807
        assert res.json_body['is_archived'] is False
3808
        assert res.json_body['is_deleted'] is False
3809
        assert res.json_body['workspace_id'] == 1
3810
        assert res.json_body['slug'] == 'genericcreatedcontent'
3811
        assert res.json_body['parent_id'] == 10
3812
        assert res.json_body['show_in_ui'] is True
3813
        assert res.json_body['sub_content_types']
3814
        assert res.json_body['file_extension'] == '.document.html'
3815
        assert res.json_body['filename'] == 'GenericCreatedContent.document.html'   # nopep8
3816
        assert res.json_body['modified']
3817
        assert res.json_body['created']
3818
        params_active = {
3819
            'parent_id': 10,
3820
            'show_archived': 0,
3821
            'show_deleted': 0,
3822
            'show_active': 1,
3823
        }
3824
        # INFO - G.M - 2018-06-165 - Verify if new content is correctly created
3825
        active_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_active, status=200).json_body  # nopep8
3826
        content_ids = [content['content_id'] for content in active_contents]
3827
        assert res.json_body['content_id'] in content_ids
3828
3829
    def test_api__post_content_create_generic_content__err_400__empty_label(self) -> None:  # nopep8
3830
        """
@@ 3577-3623 (lines=47) @@
3574
        assert 'message' in res.json.keys()
3575
        assert 'details' in res.json.keys()
3576
3577
    def test_api__post_content_create_generic_content__ok_200__nominal_case(self) -> None:  # nopep8
3578
        """
3579
        Create generic content as workspace root
3580
        """
3581
        self.testapp.authorization = (
3582
            'Basic',
3583
            (
3584
                '[email protected]',
3585
                '[email protected]'
3586
            )
3587
        )
3588
        params = {
3589
            'parent_id': None,
3590
            'label': 'GenericCreatedContent',
3591
            'content_type': 'html-document',
3592
        }
3593
        res = self.testapp.post_json(
3594
            '/api/v2/workspaces/1/contents',
3595
            params=params,
3596
            status=200
3597
        )
3598
        assert res
3599
        assert res.json_body
3600
        assert res.json_body['status'] == 'open'
3601
        assert res.json_body['content_id']
3602
        assert res.json_body['content_type'] == 'html-document'
3603
        assert res.json_body['is_archived'] is False
3604
        assert res.json_body['is_deleted'] is False
3605
        assert res.json_body['workspace_id'] == 1
3606
        assert res.json_body['slug'] == 'genericcreatedcontent'
3607
        assert res.json_body['parent_id'] is None
3608
        assert res.json_body['show_in_ui'] is True
3609
        assert res.json_body['sub_content_types']
3610
        assert res.json_body['modified']
3611
        assert res.json_body['created']
3612
        assert res.json_body['file_extension'] == '.document.html'
3613
        assert res.json_body['filename'] == 'GenericCreatedContent.document.html'   # nopep8
3614
        params_active = {
3615
            'parent_id': 0,
3616
            'show_archived': 0,
3617
            'show_deleted': 0,
3618
            'show_active': 1,
3619
        }
3620
        # INFO - G.M - 2018-06-165 - Verify if new content is correctly created
3621
        active_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_active, status=200).json_body  # nopep8
3622
        content_ids = [content['content_id'] for content in active_contents]
3623
        assert res.json_body['content_id'] in content_ids
3624
3625
    def test_api__post_content_create_generic_content__err_400__filename_already_used(self) -> None:  # nopep8
3626
        """
@@ 3683-3728 (lines=46) @@
3680
        assert 'code' in res.json.keys()
3681
        assert res.json_body['code'] == error.CONTENT_FILENAME_ALREADY_USED_IN_FOLDER
3682
3683
    def test_api__post_content_create_generic_content__ok_200__no_parent_id_param(self) -> None:  # nopep8
3684
        """
3685
        Create generic content without provided parent_id param
3686
        """
3687
        self.testapp.authorization = (
3688
            'Basic',
3689
            (
3690
                '[email protected]',
3691
                '[email protected]'
3692
            )
3693
        )
3694
        params = {
3695
            'label': 'GenericCreatedContent',
3696
            'content_type': 'html-document',
3697
        }
3698
        res = self.testapp.post_json(
3699
            '/api/v2/workspaces/1/contents',
3700
            params=params,
3701
            status=200
3702
        )
3703
        assert res
3704
        assert res.json_body
3705
        assert res.json_body['status'] == 'open'
3706
        assert res.json_body['content_id']
3707
        assert res.json_body['content_type'] == 'html-document'
3708
        assert res.json_body['is_archived'] is False
3709
        assert res.json_body['is_deleted'] is False
3710
        assert res.json_body['workspace_id'] == 1
3711
        assert res.json_body['slug'] == 'genericcreatedcontent'
3712
        assert res.json_body['parent_id'] is None
3713
        assert res.json_body['show_in_ui'] is True
3714
        assert res.json_body['sub_content_types']
3715
        assert res.json_body['file_extension'] == '.document.html'
3716
        assert res.json_body['filename'] == 'GenericCreatedContent.document.html'   # nopep8
3717
        assert res.json_body['modified']
3718
        assert res.json_body['created']
3719
        params_active = {
3720
            'parent_id': 0,
3721
            'show_archived': 0,
3722
            'show_deleted': 0,
3723
            'show_active': 1,
3724
        }
3725
        # INFO - G.M - 2018-06-165 - Verify if new content is correctly created
3726
        active_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_active, status=200).json_body  # nopep8
3727
        content_ids = [content['content_id'] for content in active_contents]
3728
        assert res.json_body['content_id'] in content_ids
3729
3730
    def test_api__post_content_create_generic_content__err_400__parent_id_0(self) -> None:  # nopep8
3731
        """