Code Duplication    Length = 48-48 lines in 5 locations

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

@@ 2929-2976 (lines=48) @@
2926
        assert res.json_body['content_id'] == 8
2927
        assert res.json_body['workspace_id'] == 1
2928
2929
    def test_api_put_move_content__ok_200__to_another_workspace_root(self):
2930
        """
2931
        Move content
2932
        move Apple_Pie (content_id: 8)
2933
        from Desserts folder(content_id: 3) to root (content_id: 0)
2934
        of workspace Business.
2935
        """
2936
        self.testapp.authorization = (
2937
            'Basic',
2938
            (
2939
                '[email protected]',
2940
                '[email protected]'
2941
            )
2942
        )
2943
        params = {
2944
            'new_parent_id': None,  # root
2945
            'new_workspace_id': '1',
2946
        }
2947
        params_folder1 = {
2948
            'parent_id': 3,
2949
            'show_archived': 0,
2950
            'show_deleted': 0,
2951
            'show_active': 1,
2952
        }
2953
        params_folder2 = {
2954
            'parent_id': 0,
2955
            'show_archived': 0,
2956
            'show_deleted': 0,
2957
            'show_active': 1,
2958
        }
2959
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2960
        folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
2961
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
2962
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
2963
        # TODO - G.M - 2018-06-163 - Check content
2964
        res = self.testapp.put_json(
2965
            '/api/v2/workspaces/2/contents/8/move',
2966
            params=params,
2967
            status=200
2968
        )
2969
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2970
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
2971
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
2972
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
2973
        assert res.json_body
2974
        assert res.json_body['parent_id'] is None
2975
        assert res.json_body['content_id'] == 8
2976
        assert res.json_body['workspace_id'] == 1
2977
2978
    def test_api_put_move_content__err_400__wrong_workspace_id(self):
2979
        """
@@ 2880-2927 (lines=48) @@
2877
        assert res.json_body['content_id'] == 8
2878
        assert res.json_body['workspace_id'] == 2
2879
2880
    def test_api_put_move_content__ok_200__to_another_workspace(self):
2881
        """
2882
        Move content
2883
        move Apple_Pie (content_id: 8)
2884
        from Desserts folder(content_id: 3) to Menus subfolder (content_id: 2)
2885
        of workspace Business.
2886
        """
2887
        self.testapp.authorization = (
2888
            'Basic',
2889
            (
2890
                '[email protected]',
2891
                '[email protected]'
2892
            )
2893
        )
2894
        params = {
2895
            'new_parent_id': '2',  # Menus
2896
            'new_workspace_id': '1',
2897
        }
2898
        params_folder1 = {
2899
            'parent_id': 3,
2900
            'show_archived': 0,
2901
            'show_deleted': 0,
2902
            'show_active': 1,
2903
        }
2904
        params_folder2 = {
2905
            'parent_id': 2,
2906
            'show_archived': 0,
2907
            'show_deleted': 0,
2908
            'show_active': 1,
2909
        }
2910
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2911
        folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
2912
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
2913
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
2914
        # TODO - G.M - 2018-06-163 - Check content
2915
        res = self.testapp.put_json(
2916
            '/api/v2/workspaces/2/contents/8/move',
2917
            params=params,
2918
            status=200
2919
        )
2920
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2921
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
2922
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
2923
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
2924
        assert res.json_body
2925
        assert res.json_body['parent_id'] == 2
2926
        assert res.json_body['content_id'] == 8
2927
        assert res.json_body['workspace_id'] == 1
2928
2929
    def test_api_put_move_content__ok_200__to_another_workspace_root(self):
2930
        """
@@ 2831-2878 (lines=48) @@
2828
        assert res.json_body['content_id'] == 8
2829
        assert res.json_body['workspace_id'] == 2
2830
2831
    def test_api_put_move_content__ok_200__with_workspace_id(self):
2832
        """
2833
        Move content
2834
        move Apple_Pie (content_id: 8)
2835
        from Desserts folder(content_id: 3) to Salads subfolder (content_id: 4)
2836
        of workspace Recipes.
2837
        """
2838
        self.testapp.authorization = (
2839
            'Basic',
2840
            (
2841
                '[email protected]',
2842
                '[email protected]'
2843
            )
2844
        )
2845
        params = {
2846
            'new_parent_id': '4',  # Salads
2847
            'new_workspace_id': '2',
2848
        }
2849
        params_folder1 = {
2850
            'parent_id': 3,
2851
            'show_archived': 0,
2852
            'show_deleted': 0,
2853
            'show_active': 1,
2854
        }
2855
        params_folder2 = {
2856
            'parent_id': 4,
2857
            'show_archived': 0,
2858
            'show_deleted': 0,
2859
            'show_active': 1,
2860
        }
2861
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2862
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2863
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
2864
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
2865
        # TODO - G.M - 2018-06-163 - Check content
2866
        res = self.testapp.put_json(
2867
            '/api/v2/workspaces/2/contents/8/move',
2868
            params=params,
2869
            status=200
2870
        )
2871
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2872
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2873
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
2874
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
2875
        assert res.json_body
2876
        assert res.json_body['parent_id'] == 4
2877
        assert res.json_body['content_id'] == 8
2878
        assert res.json_body['workspace_id'] == 2
2879
2880
    def test_api_put_move_content__ok_200__to_another_workspace(self):
2881
        """
@@ 2782-2829 (lines=48) @@
2779
        assert res.json_body['content_id'] == 8
2780
        assert res.json_body['workspace_id'] == 2
2781
2782
    def test_api_put_move_content__ok_200__to_root(self):
2783
        """
2784
        Move content
2785
        move Apple_Pie (content_id: 8)
2786
        from Desserts folder(content_id: 3) to root (content_id: 0)
2787
        of workspace Recipes.
2788
        """
2789
        self.testapp.authorization = (
2790
            'Basic',
2791
            (
2792
                '[email protected]',
2793
                '[email protected]'
2794
            )
2795
        )
2796
        params = {
2797
            'new_parent_id': None,  # root
2798
            'new_workspace_id': 2,
2799
        }
2800
        params_folder1 = {
2801
            'parent_id': 3,
2802
            'show_archived': 0,
2803
            'show_deleted': 0,
2804
            'show_active': 1,
2805
        }
2806
        params_folder2 = {
2807
            'parent_id': 0,
2808
            'show_archived': 0,
2809
            'show_deleted': 0,
2810
            'show_active': 1,
2811
        }
2812
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2813
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2814
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
2815
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
2816
        # TODO - G.M - 2018-06-163 - Check content
2817
        res = self.testapp.put_json(
2818
            '/api/v2/workspaces/2/contents/8/move',
2819
            params=params,
2820
            status=200
2821
        )
2822
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2823
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2824
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
2825
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
2826
        assert res.json_body
2827
        assert res.json_body['parent_id'] is None
2828
        assert res.json_body['content_id'] == 8
2829
        assert res.json_body['workspace_id'] == 2
2830
2831
    def test_api_put_move_content__ok_200__with_workspace_id(self):
2832
        """
@@ 2733-2780 (lines=48) @@
2730
            status=200,
2731
        )
2732
2733
    def test_api_put_move_content__ok_200__nominal_case(self):
2734
        """
2735
        Move content
2736
        move Apple_Pie (content_id: 8)
2737
        from Desserts folder(content_id: 3) to Salads subfolder (content_id: 4)
2738
        of workspace Recipes.
2739
        """
2740
        self.testapp.authorization = (
2741
            'Basic',
2742
            (
2743
                '[email protected]',
2744
                '[email protected]'
2745
            )
2746
        )
2747
        params = {
2748
            'new_parent_id': '4',  # Salads
2749
            'new_workspace_id': '2',
2750
        }
2751
        params_folder1 = {
2752
            'parent_id': 3,
2753
            'show_archived': 0,
2754
            'show_deleted': 0,
2755
            'show_active': 1,
2756
        }
2757
        params_folder2 = {
2758
            'parent_id': 4,
2759
            'show_archived': 0,
2760
            'show_deleted': 0,
2761
            'show_active': 1,
2762
        }
2763
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2764
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2765
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
2766
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
2767
        # TODO - G.M - 2018-06-163 - Check content
2768
        res = self.testapp.put_json(
2769
            '/api/v2/workspaces/2/contents/8/move',
2770
            params=params,
2771
            status=200
2772
        )
2773
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
2774
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
2775
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
2776
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
2777
        assert res.json_body
2778
        assert res.json_body['parent_id'] == 4
2779
        assert res.json_body['content_id'] == 8
2780
        assert res.json_body['workspace_id'] == 2
2781
2782
    def test_api_put_move_content__ok_200__to_root(self):
2783
        """