Code Duplication    Length = 54-55 lines in 2 locations

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

@@ 2790-2844 (lines=55) @@
2787
        item = res.all()[0]
2788
        eq_(original_id, item.content_id)
2789
2790
    def test_search_in_description(self):
2791
        # HACK - D.A. - 2015-03-09
2792
        # This test is based on a bug which does NOT return results found
2793
        # at root of a workspace (eg a folder)
2794
2795
        uapi = UserApi(
2796
            session=self.session,
2797
            config=self.app_config,
2798
            current_user=None,
2799
        )
2800
        group_api = GroupApi(
2801
            current_user=None,
2802
            session=self.session,
2803
            config=self.app_config,
2804
        )
2805
        groups = [group_api.get_one(Group.TIM_USER),
2806
                  group_api.get_one(Group.TIM_MANAGER),
2807
                  group_api.get_one(Group.TIM_ADMIN)]
2808
2809
        user = uapi.create_minimal_user(email='this.is@user',
2810
                                        groups=groups, save_now=True)
2811
2812
        workspace = WorkspaceApi(
2813
            current_user=user,
2814
            session=self.session,
2815
            config=self.app_config,
2816
        ).create_workspace(
2817
            'test workspace',
2818
            save_now=True,
2819
        )
2820
2821
        api = ContentApi(
2822
            current_user=user, 
2823
            session=self.session,
2824
            config=self.app_config,
2825
        )
2826
        a = api.create(CONTENT_TYPES.Folder.slug, workspace, None,
2827
                       'this is randomized folder', '', True)
2828
        p = api.create(CONTENT_TYPES.Page.slug, workspace, a,
2829
                       'this is dummy label content', '', True)
2830
2831
        with new_revision(
2832
            tm=transaction.manager,
2833
            session=self.session,
2834
            content=p,
2835
        ):
2836
            p.description = 'This is some amazing test'
2837
2838
        api.save(p)
2839
        original_id = p.content_id
2840
2841
        res = api.search(['dummy'])
2842
        eq_(1, len(res.all()))
2843
        item = res.all()[0]
2844
        eq_(original_id, item.content_id)
2845
2846
    def test_search_in_label_or_description(self):
2847
        # HACK - D.A. - 2015-03-09
@@ 2735-2788 (lines=54) @@
2732
        last_actives = api.get_last_active(workspace=workspace2)
2733
        assert len(last_actives) == 0
2734
2735
    def test_search_in_label(self):
2736
        # HACK - D.A. - 2015-03-09
2737
        # This test is based on a bug which does NOT return results found
2738
        # at root of a workspace (eg a folder)
2739
        uapi = UserApi(
2740
            session=self.session,
2741
            config=self.app_config,
2742
            current_user=None,
2743
        )
2744
        group_api = GroupApi(
2745
            current_user=None,
2746
            session=self.session,
2747
            config=self.app_config,
2748
        )
2749
        groups = [group_api.get_one(Group.TIM_USER),
2750
                  group_api.get_one(Group.TIM_MANAGER),
2751
                  group_api.get_one(Group.TIM_ADMIN)]
2752
2753
        user = uapi.create_minimal_user(email='this.is@user',
2754
                                        groups=groups, save_now=True)
2755
2756
        workspace = WorkspaceApi(
2757
            current_user=user,
2758
            session=self.session,
2759
            config=self.app_config,
2760
        ).create_workspace(
2761
            'test workspace',
2762
            save_now=True
2763
        )
2764
2765
        api = ContentApi(
2766
            current_user=user, 
2767
            session=self.session,
2768
            config=self.app_config,
2769
        )
2770
        a = api.create(CONTENT_TYPES.Folder.slug, workspace, None,
2771
                       'this is randomized folder', '', True)
2772
        p = api.create(CONTENT_TYPES.Page.slug, workspace, a,
2773
                       'this is randomized label content', '', True)
2774
2775
        with new_revision(
2776
            session=self.session,
2777
            tm=transaction.manager,
2778
            content=p,
2779
        ):
2780
            p.description = 'This is some amazing test'
2781
2782
        api.save(p)
2783
        original_id = p.content_id
2784
2785
        res = api.search(['randomized'])
2786
        eq_(1, len(res.all()))
2787
        item = res.all()[0]
2788
        eq_(original_id, item.content_id)
2789
2790
    def test_search_in_description(self):
2791
        # HACK - D.A. - 2015-03-09