Code Duplication    Length = 35-37 lines in 5 locations

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

@@ 1955-1991 (lines=37) @@
1952
        assert set(content['sub_content_types']) == {'comment'}
1953
        assert content['workspace_id'] == 3
1954
1955
    def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
1956
        """
1957
         Check obtain workspace root deleted contents
1958
         """
1959
        params = {
1960
            'parent_id': 0,
1961
            'show_archived': 0,
1962
            'show_deleted': 1,
1963
            'show_active': 0,
1964
        }
1965
        self.testapp.authorization = (
1966
            'Basic',
1967
            (
1968
                '[email protected]',
1969
                'foobarbaz'
1970
            )
1971
        )
1972
        res = self.testapp.get(
1973
            '/api/v2/workspaces/3/contents',
1974
            status=200,
1975
            params=params,
1976
        ).json_body   # nopep8
1977
        # TODO - G.M - 30-05-2018 - Check this test
1978
1979
        assert len(res) == 1
1980
        content = res[0]
1981
        assert content['content_type'] == 'html-document'
1982
        assert content['content_id'] == 17
1983
        assert content['is_archived'] is False
1984
        assert content['is_deleted'] is True
1985
        assert content['label'].startswith('Bad Fruit Salad')
1986
        assert content['parent_id'] is None
1987
        assert content['show_in_ui'] is True
1988
        assert content['slug'].startswith('bad-fruit-salad')
1989
        assert content['status'] == 'open'
1990
        assert set(content['sub_content_types']) == {'comment'}
1991
        assert content['workspace_id'] == 3
1992
1993
    def test_api__get_workspace_content__ok_200__get_nothing_root_content(self):
1994
        """
@@ 2360-2395 (lines=36) @@
2357
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2358
        assert content['workspace_id'] == 2
2359
2360
    def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
2361
        """
2362
         Check obtain workspace folder deleted contents
2363
         """
2364
        params = {
2365
            'parent_id': 10,
2366
            'show_archived': 0,
2367
            'show_deleted': 1,
2368
            'show_active': 0,
2369
        }
2370
        self.testapp.authorization = (
2371
            'Basic',
2372
            (
2373
                '[email protected]',
2374
                '[email protected]'
2375
            )
2376
        )
2377
        res = self.testapp.get(
2378
            '/api/v2/workspaces/2/contents',
2379
            status=200,
2380
            params=params,
2381
        ).json_body   # nopep8
2382
2383
        assert len(res) == 1
2384
        content = res[0]
2385
        assert content['content_type'] == 'html-document'
2386
        assert content['content_id'] == 14
2387
        assert content['is_archived'] is False
2388
        assert content['is_deleted'] is True
2389
        assert content['label'].startswith('Bad Fruit Salad')
2390
        assert content['parent_id'] == 10
2391
        assert content['show_in_ui'] is True
2392
        assert content['slug'].startswith('bad-fruit-salad')
2393
        assert content['status'] == 'open'
2394
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2395
        assert content['workspace_id'] == 2
2396
2397
    def test_api__get_workspace_content__ok_200__get_nothing_folder_content(self):  # nopep8
2398
        """
@@ 2324-2358 (lines=35) @@
2321
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2322
        assert content['workspace_id'] == 2
2323
2324
    def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
2325
        """
2326
         Check obtain workspace folder archived contents
2327
         """
2328
        params = {
2329
            'parent_id': 10,
2330
            'show_archived': 1,
2331
            'show_deleted': 0,
2332
            'show_active': 0,
2333
        }
2334
        self.testapp.authorization = (
2335
            'Basic',
2336
            (
2337
                '[email protected]',
2338
                '[email protected]'
2339
            )
2340
        )
2341
        res = self.testapp.get(
2342
            '/api/v2/workspaces/2/contents',
2343
            status=200,
2344
            params=params,
2345
        ).json_body   # nopep8
2346
        assert len(res) == 1
2347
        content = res[0]
2348
        assert content['content_type'] == 'html-document'
2349
        assert content['content_id'] == 13
2350
        assert content['is_archived'] is True
2351
        assert content['is_deleted'] is False
2352
        assert content['label'].startswith('Fruit Salad')
2353
        assert content['parent_id'] == 10
2354
        assert content['show_in_ui'] is True
2355
        assert content['slug'].startswith('fruit-salad')
2356
        assert content['status'] == 'open'
2357
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2358
        assert content['workspace_id'] == 2
2359
2360
    def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
2361
        """
@@ 2288-2322 (lines=35) @@
2285
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2286
        assert content['workspace_id'] == 2
2287
2288
    def test_api__get_workspace_content__ok_200__get_only_active_folder_content(self):  # nopep8
2289
        """
2290
         Check obtain workspace folder active contents
2291
         """
2292
        params = {
2293
            'parent_id': 10,
2294
            'show_archived': 0,
2295
            'show_deleted': 0,
2296
            'show_active': 1,
2297
        }
2298
        self.testapp.authorization = (
2299
            'Basic',
2300
            (
2301
                '[email protected]',
2302
                '[email protected]'
2303
            )
2304
        )
2305
        res = self.testapp.get(
2306
            '/api/v2/workspaces/2/contents',
2307
            status=200,
2308
            params=params,
2309
        ).json_body   # nopep8
2310
        assert len(res) == 1
2311
        content = res[0]
2312
        assert content['content_type']
2313
        assert content['content_id'] == 12
2314
        assert content['is_archived'] is False
2315
        assert content['is_deleted'] is False
2316
        assert content['label'] == 'New Fruit Salad'
2317
        assert content['parent_id'] == 10
2318
        assert content['show_in_ui'] is True
2319
        assert content['slug'] == 'new-fruit-salad'
2320
        assert content['status'] == 'open'
2321
        assert set(content['sub_content_types']) == {'comment'}  # nopep8
2322
        assert content['workspace_id'] == 2
2323
2324
    def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
2325
        """
@@ 1919-1953 (lines=35) @@
1916
        assert set(content['sub_content_types']) == {'comment'}
1917
        assert content['workspace_id'] == 3
1918
1919
    def test_api__get_workspace_content__ok_200__get_only_archived_root_content(self):  # nopep8
1920
        """
1921
        Check obtain workspace root archived contents
1922
        """
1923
        params = {
1924
            'parent_id': 0,
1925
            'show_archived': 1,
1926
            'show_deleted': 0,
1927
            'show_active': 0,
1928
        }
1929
        self.testapp.authorization = (
1930
            'Basic',
1931
            (
1932
                '[email protected]',
1933
                'foobarbaz'
1934
            )
1935
        )
1936
        res = self.testapp.get(
1937
            '/api/v2/workspaces/3/contents',
1938
            status=200,
1939
            params=params,
1940
        ).json_body   # nopep8
1941
        assert len(res) == 1
1942
        content = res[0]
1943
        assert content['content_type'] == 'html-document'
1944
        assert content['content_id'] == 16
1945
        assert content['is_archived'] is True
1946
        assert content['is_deleted'] is False
1947
        assert content['label'].startswith('Fruit Salad')
1948
        assert content['parent_id'] is None
1949
        assert content['show_in_ui'] is True
1950
        assert content['slug'].startswith('fruit-salad')
1951
        assert content['status'] == 'open'
1952
        assert set(content['sub_content_types']) == {'comment'}
1953
        assert content['workspace_id'] == 3
1954
1955
    def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
1956
        """