Code Duplication    Length = 54-55 lines in 2 locations

backend/tracim_backend/tests/library/test_content_api.py 2 locations

@@ 3836-3890 (lines=55) @@
3833
        item = res.all()[0]
3834
        eq_(original_id, item.content_id)
3835
3836
    def test_search_in_description(self):
3837
        # HACK - D.A. - 2015-03-09
3838
        # This test is based on a bug which does NOT return results found
3839
        # at root of a workspace (eg a folder)
3840
3841
        uapi = UserApi(
3842
            session=self.session,
3843
            config=self.app_config,
3844
            current_user=None,
3845
        )
3846
        group_api = GroupApi(
3847
            current_user=None,
3848
            session=self.session,
3849
            config=self.app_config,
3850
        )
3851
        groups = [group_api.get_one(Group.TIM_USER),
3852
                  group_api.get_one(Group.TIM_MANAGER),
3853
                  group_api.get_one(Group.TIM_ADMIN)]
3854
3855
        user = uapi.create_minimal_user(email='this.is@user',
3856
                                        groups=groups, save_now=True)
3857
3858
        workspace = WorkspaceApi(
3859
            current_user=user,
3860
            session=self.session,
3861
            config=self.app_config,
3862
        ).create_workspace(
3863
            'test workspace',
3864
            save_now=True,
3865
        )
3866
3867
        api = ContentApi(
3868
            current_user=user, 
3869
            session=self.session,
3870
            config=self.app_config,
3871
        )
3872
        a = api.create(content_type_list.Folder.slug, workspace, None,
3873
                       'this is randomized folder', '', True)
3874
        p = api.create(content_type_list.Page.slug, workspace, a,
3875
                       'this is dummy label content', '', True)
3876
3877
        with new_revision(
3878
            tm=transaction.manager,
3879
            session=self.session,
3880
            content=p,
3881
        ):
3882
            p.description = 'This is some amazing test'
3883
3884
        api.save(p)
3885
        original_id = p.content_id
3886
3887
        res = api.search(['dummy'])
3888
        eq_(1, len(res.all()))
3889
        item = res.all()[0]
3890
        eq_(original_id, item.content_id)
3891
3892
    def test_search_in_label_or_description(self):
3893
        # HACK - D.A. - 2015-03-09
@@ 3781-3834 (lines=54) @@
3778
        last_actives = api.get_last_active(workspace=workspace2)
3779
        assert len(last_actives) == 0
3780
3781
    def test_search_in_label(self):
3782
        # HACK - D.A. - 2015-03-09
3783
        # This test is based on a bug which does NOT return results found
3784
        # at root of a workspace (eg a folder)
3785
        uapi = UserApi(
3786
            session=self.session,
3787
            config=self.app_config,
3788
            current_user=None,
3789
        )
3790
        group_api = GroupApi(
3791
            current_user=None,
3792
            session=self.session,
3793
            config=self.app_config,
3794
        )
3795
        groups = [group_api.get_one(Group.TIM_USER),
3796
                  group_api.get_one(Group.TIM_MANAGER),
3797
                  group_api.get_one(Group.TIM_ADMIN)]
3798
3799
        user = uapi.create_minimal_user(email='this.is@user',
3800
                                        groups=groups, save_now=True)
3801
3802
        workspace = WorkspaceApi(
3803
            current_user=user,
3804
            session=self.session,
3805
            config=self.app_config,
3806
        ).create_workspace(
3807
            'test workspace',
3808
            save_now=True
3809
        )
3810
3811
        api = ContentApi(
3812
            current_user=user, 
3813
            session=self.session,
3814
            config=self.app_config,
3815
        )
3816
        a = api.create(content_type_list.Folder.slug, workspace, None,
3817
                       'this is randomized folder', '', True)
3818
        p = api.create(content_type_list.Page.slug, workspace, a,
3819
                       'this is randomized label content', '', True)
3820
3821
        with new_revision(
3822
            session=self.session,
3823
            tm=transaction.manager,
3824
            content=p,
3825
        ):
3826
            p.description = 'This is some amazing test'
3827
3828
        api.save(p)
3829
        original_id = p.content_id
3830
3831
        res = api.search(['randomized'])
3832
        eq_(1, len(res.all()))
3833
        item = res.all()[0]
3834
        eq_(original_id, item.content_id)
3835
3836
    def test_search_in_description(self):
3837
        # HACK - D.A. - 2015-03-09