Code Duplication    Length = 35-37 lines in 5 locations

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

@@ 2374-2410 (lines=37) @@
2371
        assert set(content['sub_content_types']) == {'comment'}
2372
        assert content['workspace_id'] == 3
2373
2374
    def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
2375
        """
2376
         Check obtain workspace root deleted contents
2377
         """
2378
        params = {
2379
            'parent_id': 0,
2380
            'show_archived': 0,
2381
            'show_deleted': 1,
2382
            'show_active': 0,
2383
        }
2384
        self.testapp.authorization = (
2385
            'Basic',
2386
            (
2387
                '[email protected]',
2388
                'foobarbaz'
2389
            )
2390
        )
2391
        res = self.testapp.get(
2392
            '/api/v2/workspaces/3/contents',
2393
            status=200,
2394
            params=params,
2395
        ).json_body   # nopep8
2396
        # TODO - G.M - 30-05-2018 - Check this test
2397
2398
        assert len(res) == 1
2399
        content = res[0]
2400
        assert content['content_type'] == 'html-document'
2401
        assert content['content_id'] == 17
2402
        assert content['is_archived'] is False
2403
        assert content['is_deleted'] is True
2404
        assert content['label'].startswith('Bad Fruit Salad')
2405
        assert content['parent_id'] is None
2406
        assert content['show_in_ui'] is True
2407
        assert content['slug'].startswith('bad-fruit-salad')
2408
        assert content['status'] == 'open'
2409
        assert set(content['sub_content_types']) == {'comment'}
2410
        assert content['workspace_id'] == 3
2411
2412
    def test_api__get_workspace_content__ok_200__get_nothing_root_content(self):
2413
        """
@@ 2799-2834 (lines=36) @@
2796
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2797
        assert content['workspace_id'] == 2
2798
2799
    def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
2800
        """
2801
         Check obtain workspace folder deleted contents
2802
         """
2803
        params = {
2804
            'parent_id': 10,
2805
            'show_archived': 0,
2806
            'show_deleted': 1,
2807
            'show_active': 0,
2808
        }
2809
        self.testapp.authorization = (
2810
            'Basic',
2811
            (
2812
                '[email protected]',
2813
                '[email protected]'
2814
            )
2815
        )
2816
        res = self.testapp.get(
2817
            '/api/v2/workspaces/2/contents',
2818
            status=200,
2819
            params=params,
2820
        ).json_body   # nopep8
2821
2822
        assert len(res) == 1
2823
        content = res[0]
2824
        assert content['content_type'] == 'html-document'
2825
        assert content['content_id'] == 14
2826
        assert content['is_archived'] is False
2827
        assert content['is_deleted'] is True
2828
        assert content['label'].startswith('Bad Fruit Salad')
2829
        assert content['parent_id'] == 10
2830
        assert content['show_in_ui'] is True
2831
        assert content['slug'].startswith('bad-fruit-salad')
2832
        assert content['status'] == 'open'
2833
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2834
        assert content['workspace_id'] == 2
2835
2836
    def test_api__get_workspace_content__ok_200__get_nothing_folder_content(self):  # nopep8
2837
        """
@@ 2763-2797 (lines=35) @@
2760
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2761
        assert content['workspace_id'] == 2
2762
2763
    def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
2764
        """
2765
         Check obtain workspace folder archived contents
2766
         """
2767
        params = {
2768
            'parent_id': 10,
2769
            'show_archived': 1,
2770
            'show_deleted': 0,
2771
            'show_active': 0,
2772
        }
2773
        self.testapp.authorization = (
2774
            'Basic',
2775
            (
2776
                '[email protected]',
2777
                '[email protected]'
2778
            )
2779
        )
2780
        res = self.testapp.get(
2781
            '/api/v2/workspaces/2/contents',
2782
            status=200,
2783
            params=params,
2784
        ).json_body   # nopep8
2785
        assert len(res) == 1
2786
        content = res[0]
2787
        assert content['content_type'] == 'html-document'
2788
        assert content['content_id'] == 13
2789
        assert content['is_archived'] is True
2790
        assert content['is_deleted'] is False
2791
        assert content['label'].startswith('Fruit Salad')
2792
        assert content['parent_id'] == 10
2793
        assert content['show_in_ui'] is True
2794
        assert content['slug'].startswith('fruit-salad')
2795
        assert content['status'] == 'open'
2796
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2797
        assert content['workspace_id'] == 2
2798
2799
    def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
2800
        """
@@ 2727-2761 (lines=35) @@
2724
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2725
        assert content['workspace_id'] == 2
2726
2727
    def test_api__get_workspace_content__ok_200__get_only_active_folder_content(self):  # nopep8
2728
        """
2729
         Check obtain workspace folder active contents
2730
         """
2731
        params = {
2732
            'parent_id': 10,
2733
            'show_archived': 0,
2734
            'show_deleted': 0,
2735
            'show_active': 1,
2736
        }
2737
        self.testapp.authorization = (
2738
            'Basic',
2739
            (
2740
                '[email protected]',
2741
                '[email protected]'
2742
            )
2743
        )
2744
        res = self.testapp.get(
2745
            '/api/v2/workspaces/2/contents',
2746
            status=200,
2747
            params=params,
2748
        ).json_body   # nopep8
2749
        assert len(res) == 1
2750
        content = res[0]
2751
        assert content['content_type']
2752
        assert content['content_id'] == 12
2753
        assert content['is_archived'] is False
2754
        assert content['is_deleted'] is False
2755
        assert content['label'] == 'New Fruit Salad'
2756
        assert content['parent_id'] == 10
2757
        assert content['show_in_ui'] is True
2758
        assert content['slug'] == 'new-fruit-salad'
2759
        assert content['status'] == 'open'
2760
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2761
        assert content['workspace_id'] == 2
2762
2763
    def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
2764
        """
@@ 2338-2372 (lines=35) @@
2335
        assert set(content['sub_content_types']) == {'comment'}
2336
        assert content['workspace_id'] == 3
2337
2338
    def test_api__get_workspace_content__ok_200__get_only_archived_root_content(self):  # nopep8
2339
        """
2340
        Check obtain workspace root archived contents
2341
        """
2342
        params = {
2343
            'parent_id': 0,
2344
            'show_archived': 1,
2345
            'show_deleted': 0,
2346
            'show_active': 0,
2347
        }
2348
        self.testapp.authorization = (
2349
            'Basic',
2350
            (
2351
                '[email protected]',
2352
                'foobarbaz'
2353
            )
2354
        )
2355
        res = self.testapp.get(
2356
            '/api/v2/workspaces/3/contents',
2357
            status=200,
2358
            params=params,
2359
        ).json_body   # nopep8
2360
        assert len(res) == 1
2361
        content = res[0]
2362
        assert content['content_type'] == 'html-document'
2363
        assert content['content_id'] == 16
2364
        assert content['is_archived'] is True
2365
        assert content['is_deleted'] is False
2366
        assert content['label'].startswith('Fruit Salad')
2367
        assert content['parent_id'] is None
2368
        assert content['show_in_ui'] is True
2369
        assert content['slug'].startswith('fruit-salad')
2370
        assert content['status'] == 'open'
2371
        assert set(content['sub_content_types']) == {'comment'}
2372
        assert content['workspace_id'] == 3
2373
2374
    def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
2375
        """