Code Duplication    Length = 47-49 lines in 2 locations

backend/tracim_backend/tests/functional/test_contents.py 2 locations

@@ 366-414 (lines=49) @@
363
            status=400
364
        )
365
366
    def test_api__update_folder__err_400__empty_label(self) -> None:  # nopep8
367
        """
368
        Update(put) one folder content
369
        """
370
        dbsession = get_tm_session(self.session_factory, transaction.manager)
371
        admin = dbsession.query(models.User) \
372
            .filter(models.User.email == '[email protected]') \
373
            .one()
374
        workspace_api = WorkspaceApi(
375
            current_user=admin,
376
            session=dbsession,
377
            config=self.app_config
378
        )
379
        content_api = ContentApi(
380
            current_user=admin,
381
            session=dbsession,
382
            config=self.app_config
383
        )
384
        test_workspace = workspace_api.create_workspace(
385
            label='test',
386
            save_now=True,
387
        )
388
        folder = content_api.create(
389
            label='test_folder',
390
            content_type_slug=CONTENT_TYPES.Folder.slug,
391
            workspace=test_workspace,
392
            do_save=True,
393
            do_notify=False
394
        )
395
        transaction.commit()
396
        self.testapp.authorization = (
397
            'Basic',
398
            (
399
                '[email protected]',
400
                '[email protected]'
401
            )
402
        )
403
        params = {
404
            'label': '',
405
            'raw_content': '<p> Le nouveau contenu </p>',
406
            'sub_content_types': [CONTENT_TYPES.Folder.slug]
407
        }
408
        self.testapp.put_json(
409
            '/api/v2/workspaces/{workspace_id}/folders/{content_id}'.format(
410
                workspace_id=test_workspace.workspace_id,
411
                content_id=folder.content_id,
412
            ),
413
            params=params,
414
            status=400
415
        )
416
417
    def test_api__update_folder__ok_200__nominal_case(self) -> None:
@@ 797-843 (lines=47) @@
794
        assert content['content_id'] == folder.content_id
795
        assert content['status'] == 'closed-deprecated'
796
797
    def test_api__set_folder_status__err_400__wrong_status(self) -> None:
798
        """
799
        Get one folder content
800
        """
801
        self.testapp.authorization = (
802
            'Basic',
803
            (
804
                '[email protected]',
805
                '[email protected]'
806
            )
807
        )
808
        params = {
809
            'status': 'unexistant-status',
810
        }
811
        dbsession = get_tm_session(self.session_factory, transaction.manager)
812
        admin = dbsession.query(models.User) \
813
            .filter(models.User.email == '[email protected]') \
814
            .one()
815
        workspace_api = WorkspaceApi(
816
            current_user=admin,
817
            session=dbsession,
818
            config=self.app_config
819
        )
820
        content_api = ContentApi(
821
            current_user=admin,
822
            session=dbsession,
823
            config=self.app_config
824
        )
825
        test_workspace = workspace_api.create_workspace(
826
            label='test',
827
            save_now=True,
828
        )
829
        folder = content_api.create(
830
            label='test_folder',
831
            content_type_slug=CONTENT_TYPES.Folder.slug,
832
            workspace=test_workspace,
833
            do_save=True,
834
            do_notify=False
835
        )
836
        transaction.commit()
837
        self.testapp.put_json(
838
            '/api/v2/workspaces/{workspace_id}/folders/{content_id}/status'.format(  # nopep8
839
                workspace_id=test_workspace.workspace_id,
840
                content_id=folder.content_id,
841
            ),
842
            params=params,
843
            status=400
844
        )
845
846