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:
@@ 740-786 (lines=47) @@
737
        assert content['content_id'] == folder.content_id
738
        assert content['status'] == 'closed-deprecated'
739
740
    def test_api__set_folder_status__err_400__wrong_status(self) -> None:
741
        """
742
        Get one folder content
743
        """
744
        self.testapp.authorization = (
745
            'Basic',
746
            (
747
                '[email protected]',
748
                '[email protected]'
749
            )
750
        )
751
        params = {
752
            'status': 'unexistant-status',
753
        }
754
        dbsession = get_tm_session(self.session_factory, transaction.manager)
755
        admin = dbsession.query(models.User) \
756
            .filter(models.User.email == '[email protected]') \
757
            .one()
758
        workspace_api = WorkspaceApi(
759
            current_user=admin,
760
            session=dbsession,
761
            config=self.app_config
762
        )
763
        content_api = ContentApi(
764
            current_user=admin,
765
            session=dbsession,
766
            config=self.app_config
767
        )
768
        test_workspace = workspace_api.create_workspace(
769
            label='test',
770
            save_now=True,
771
        )
772
        folder = content_api.create(
773
            label='test_folder',
774
            content_type_slug=CONTENT_TYPES.Folder.slug,
775
            workspace=test_workspace,
776
            do_save=True,
777
            do_notify=False
778
        )
779
        transaction.commit()
780
        self.testapp.put_json(
781
            '/api/v2/workspaces/{workspace_id}/folders/{content_id}/status'.format(  # nopep8
782
                workspace_id=test_workspace.workspace_id,
783
                content_id=folder.content_id,
784
            ),
785
            params=params,
786
            status=400
787
        )
788
789