Code Duplication    Length = 48-48 lines in 5 locations

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

@@ 3418-3465 (lines=48) @@
3415
        assert res.json_body['content_id'] == 8
3416
        assert res.json_body['workspace_id'] == 1
3417
3418
    def test_api_put_move_content__ok_200__to_another_workspace_root(self):
3419
        """
3420
        Move content
3421
        move Apple_Pie (content_id: 8)
3422
        from Desserts folder(content_id: 3) to root (content_id: 0)
3423
        of workspace Business.
3424
        """
3425
        self.testapp.authorization = (
3426
            'Basic',
3427
            (
3428
                '[email protected]',
3429
                '[email protected]'
3430
            )
3431
        )
3432
        params = {
3433
            'new_parent_id': None,  # root
3434
            'new_workspace_id': '1',
3435
        }
3436
        params_folder1 = {
3437
            'parent_id': 3,
3438
            'show_archived': 0,
3439
            'show_deleted': 0,
3440
            'show_active': 1,
3441
        }
3442
        params_folder2 = {
3443
            'parent_id': 0,
3444
            'show_archived': 0,
3445
            'show_deleted': 0,
3446
            'show_active': 1,
3447
        }
3448
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3449
        folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
3450
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
3451
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
3452
        # TODO - G.M - 2018-06-163 - Check content
3453
        res = self.testapp.put_json(
3454
            '/api/v2/workspaces/2/contents/8/move',
3455
            params=params,
3456
            status=200
3457
        )
3458
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3459
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
3460
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
3461
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
3462
        assert res.json_body
3463
        assert res.json_body['parent_id'] is None
3464
        assert res.json_body['content_id'] == 8
3465
        assert res.json_body['workspace_id'] == 1
3466
3467
    def test_api_put_move_content__err_400__wrong_workspace_id(self):
3468
        """
@@ 3369-3416 (lines=48) @@
3366
        assert res.json_body['content_id'] == 8
3367
        assert res.json_body['workspace_id'] == 2
3368
3369
    def test_api_put_move_content__ok_200__to_another_workspace(self):
3370
        """
3371
        Move content
3372
        move Apple_Pie (content_id: 8)
3373
        from Desserts folder(content_id: 3) to Menus subfolder (content_id: 2)
3374
        of workspace Business.
3375
        """
3376
        self.testapp.authorization = (
3377
            'Basic',
3378
            (
3379
                '[email protected]',
3380
                '[email protected]'
3381
            )
3382
        )
3383
        params = {
3384
            'new_parent_id': '2',  # Menus
3385
            'new_workspace_id': '1',
3386
        }
3387
        params_folder1 = {
3388
            'parent_id': 3,
3389
            'show_archived': 0,
3390
            'show_deleted': 0,
3391
            'show_active': 1,
3392
        }
3393
        params_folder2 = {
3394
            'parent_id': 2,
3395
            'show_archived': 0,
3396
            'show_deleted': 0,
3397
            'show_active': 1,
3398
        }
3399
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3400
        folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
3401
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
3402
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
3403
        # TODO - G.M - 2018-06-163 - Check content
3404
        res = self.testapp.put_json(
3405
            '/api/v2/workspaces/2/contents/8/move',
3406
            params=params,
3407
            status=200
3408
        )
3409
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3410
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/1/contents', params=params_folder2, status=200).json_body  # nopep8
3411
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
3412
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
3413
        assert res.json_body
3414
        assert res.json_body['parent_id'] == 2
3415
        assert res.json_body['content_id'] == 8
3416
        assert res.json_body['workspace_id'] == 1
3417
3418
    def test_api_put_move_content__ok_200__to_another_workspace_root(self):
3419
        """
@@ 3320-3367 (lines=48) @@
3317
        assert res.json_body['content_id'] == 8
3318
        assert res.json_body['workspace_id'] == 2
3319
3320
    def test_api_put_move_content__ok_200__with_workspace_id(self):
3321
        """
3322
        Move content
3323
        move Apple_Pie (content_id: 8)
3324
        from Desserts folder(content_id: 3) to Salads subfolder (content_id: 4)
3325
        of workspace Recipes.
3326
        """
3327
        self.testapp.authorization = (
3328
            'Basic',
3329
            (
3330
                '[email protected]',
3331
                '[email protected]'
3332
            )
3333
        )
3334
        params = {
3335
            'new_parent_id': '4',  # Salads
3336
            'new_workspace_id': '2',
3337
        }
3338
        params_folder1 = {
3339
            'parent_id': 3,
3340
            'show_archived': 0,
3341
            'show_deleted': 0,
3342
            'show_active': 1,
3343
        }
3344
        params_folder2 = {
3345
            'parent_id': 4,
3346
            'show_archived': 0,
3347
            'show_deleted': 0,
3348
            'show_active': 1,
3349
        }
3350
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3351
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3352
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
3353
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
3354
        # TODO - G.M - 2018-06-163 - Check content
3355
        res = self.testapp.put_json(
3356
            '/api/v2/workspaces/2/contents/8/move',
3357
            params=params,
3358
            status=200
3359
        )
3360
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3361
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3362
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
3363
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
3364
        assert res.json_body
3365
        assert res.json_body['parent_id'] == 4
3366
        assert res.json_body['content_id'] == 8
3367
        assert res.json_body['workspace_id'] == 2
3368
3369
    def test_api_put_move_content__ok_200__to_another_workspace(self):
3370
        """
@@ 3271-3318 (lines=48) @@
3268
        assert res.json_body['content_id'] == 8
3269
        assert res.json_body['workspace_id'] == 2
3270
3271
    def test_api_put_move_content__ok_200__to_root(self):
3272
        """
3273
        Move content
3274
        move Apple_Pie (content_id: 8)
3275
        from Desserts folder(content_id: 3) to root (content_id: 0)
3276
        of workspace Recipes.
3277
        """
3278
        self.testapp.authorization = (
3279
            'Basic',
3280
            (
3281
                '[email protected]',
3282
                '[email protected]'
3283
            )
3284
        )
3285
        params = {
3286
            'new_parent_id': None,  # root
3287
            'new_workspace_id': 2,
3288
        }
3289
        params_folder1 = {
3290
            'parent_id': 3,
3291
            'show_archived': 0,
3292
            'show_deleted': 0,
3293
            'show_active': 1,
3294
        }
3295
        params_folder2 = {
3296
            'parent_id': 0,
3297
            'show_archived': 0,
3298
            'show_deleted': 0,
3299
            'show_active': 1,
3300
        }
3301
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3302
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3303
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
3304
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
3305
        # TODO - G.M - 2018-06-163 - Check content
3306
        res = self.testapp.put_json(
3307
            '/api/v2/workspaces/2/contents/8/move',
3308
            params=params,
3309
            status=200
3310
        )
3311
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3312
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3313
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
3314
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
3315
        assert res.json_body
3316
        assert res.json_body['parent_id'] is None
3317
        assert res.json_body['content_id'] == 8
3318
        assert res.json_body['workspace_id'] == 2
3319
3320
    def test_api_put_move_content__ok_200__with_workspace_id(self):
3321
        """
@@ 3222-3269 (lines=48) @@
3219
            status=200,
3220
        )
3221
3222
    def test_api_put_move_content__ok_200__nominal_case(self):
3223
        """
3224
        Move content
3225
        move Apple_Pie (content_id: 8)
3226
        from Desserts folder(content_id: 3) to Salads subfolder (content_id: 4)
3227
        of workspace Recipes.
3228
        """
3229
        self.testapp.authorization = (
3230
            'Basic',
3231
            (
3232
                '[email protected]',
3233
                '[email protected]'
3234
            )
3235
        )
3236
        params = {
3237
            'new_parent_id': '4',  # Salads
3238
            'new_workspace_id': '2',
3239
        }
3240
        params_folder1 = {
3241
            'parent_id': 3,
3242
            'show_archived': 0,
3243
            'show_deleted': 0,
3244
            'show_active': 1,
3245
        }
3246
        params_folder2 = {
3247
            'parent_id': 4,
3248
            'show_archived': 0,
3249
            'show_deleted': 0,
3250
            'show_active': 1,
3251
        }
3252
        folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3253
        folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3254
        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
3255
        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
3256
        # TODO - G.M - 2018-06-163 - Check content
3257
        res = self.testapp.put_json(
3258
            '/api/v2/workspaces/2/contents/8/move',
3259
            params=params,
3260
            status=200
3261
        )
3262
        new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
3263
        new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
3264
        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
3265
        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
3266
        assert res.json_body
3267
        assert res.json_body['parent_id'] == 4
3268
        assert res.json_body['content_id'] == 8
3269
        assert res.json_body['workspace_id'] == 2
3270
3271
    def test_api_put_move_content__ok_200__to_root(self):
3272
        """