Code Duplication    Length = 53-53 lines in 2 locations

tracim/tests/library/test_content_api.py 2 locations

@@ 1833-1885 (lines=53) @@
1830
        item = res.all()[0]
1831
        eq_(original_id, item.content_id)
1832
1833
    def test_search_in_description(self):
1834
        # HACK - D.A. - 2015-03-09
1835
        # This test is based on a bug which does NOT return results found
1836
        # at root of a workspace (eg a folder)
1837
1838
        uapi = UserApi(
1839
            session=self.session,
1840
            config=self.app_config,
1841
            current_user=None,
1842
        )
1843
        group_api = GroupApi(
1844
            current_user=None,
1845
            session=self.session,
1846
        )
1847
        groups = [group_api.get_one(Group.TIM_USER),
1848
                  group_api.get_one(Group.TIM_MANAGER),
1849
                  group_api.get_one(Group.TIM_ADMIN)]
1850
1851
        user = uapi.create_user(email='this.is@user',
1852
                                groups=groups, save_now=True)
1853
1854
        workspace = WorkspaceApi(
1855
            current_user=user,
1856
            session=self.session
1857
        ).create_workspace(
1858
            'test workspace',
1859
            save_now=True,
1860
        )
1861
1862
        api = ContentApi(
1863
            current_user=user, 
1864
            session=self.session,
1865
            config=self.app_config,
1866
        )
1867
        a = api.create(ContentType.Folder, workspace, None,
1868
                       'this is randomized folder', True)
1869
        p = api.create(ContentType.Page, workspace, a,
1870
                       'this is dummy label content', True)
1871
1872
        with new_revision(
1873
            tm=transaction.manager,
1874
            session=self.session,
1875
            content=p,
1876
        ):
1877
            p.description = 'This is some amazing test'
1878
1879
        api.save(p)
1880
        original_id = p.content_id
1881
1882
        res = api.search(['dummy'])
1883
        eq_(1, len(res.all()))
1884
        item = res.all()[0]
1885
        eq_(original_id, item.content_id)
1886
1887
    def test_search_in_label_or_description(self):
1888
        # HACK - D.A. - 2015-03-09
@@ 1779-1831 (lines=53) @@
1776
        eq_(ActionDescription.UNDELETION, updated2.revision_type)
1777
        eq_(u1id, updated2.owner_id)
1778
1779
    def test_search_in_label(self):
1780
        # HACK - D.A. - 2015-03-09
1781
        # This test is based on a bug which does NOT return results found
1782
        # at root of a workspace (eg a folder)
1783
        uapi = UserApi(
1784
            session=self.session,
1785
            config=self.app_config,
1786
            current_user=None,
1787
        )
1788
        group_api = GroupApi(
1789
            current_user=None,
1790
            session=self.session,
1791
        )
1792
        groups = [group_api.get_one(Group.TIM_USER),
1793
                  group_api.get_one(Group.TIM_MANAGER),
1794
                  group_api.get_one(Group.TIM_ADMIN)]
1795
1796
        user = uapi.create_user(email='this.is@user',
1797
                                groups=groups, save_now=True)
1798
1799
        workspace = WorkspaceApi(
1800
            current_user=user,
1801
            session=self.session
1802
        ).create_workspace(
1803
            'test workspace',
1804
            save_now=True
1805
        )
1806
1807
        api = ContentApi(
1808
            current_user=user, 
1809
            session=self.session,
1810
            config=self.app_config,
1811
1812
        )
1813
        a = api.create(ContentType.Folder, workspace, None,
1814
                       'this is randomized folder', True)
1815
        p = api.create(ContentType.Page, workspace, a,
1816
                       'this is randomized label content', True)
1817
1818
        with new_revision(
1819
            session=self.session,
1820
            tm=transaction.manager,
1821
            content=p,
1822
        ):
1823
            p.description = 'This is some amazing test'
1824
1825
        api.save(p)
1826
        original_id = p.content_id
1827
1828
        res = api.search(['randomized'])
1829
        eq_(1, len(res.all()))
1830
        item = res.all()[0]
1831
        eq_(original_id, item.content_id)
1832
1833
    def test_search_in_description(self):
1834
        # HACK - D.A. - 2015-03-09