def test_querylisting_results(self): api.content.create(type='Document', id='page1', container=self.portal, subject=('foobar', )) api.content.create(type='Document', id='page2', container=self.portal, subject=('foobar', )) api.content.create(type='Document', id='page3', container=self.portal, subject=('foobar', 'foobar2')) api.content.create(type='Document', id='page4', container=self.portal, subject=('foobar', 'foobar2')) data = { 'query': [{ 'i': 'Subject', 'o': 'plone.app.querystring.operation.list.contains', 'v': 'foobar2' }], 'available_tags': ('foobar2', ) } tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', data) self.assertEqual(tile.results()['total'], 2) self.request.form.update({'Subject': 'foobar'}) tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', data) self.assertEqual(tile.results()['total'], 2)
def test_es_querylisting_unicode_issue(self): tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', {}) # should not cause errors... self.request.form.update({'Title': 'ma\xf1on'}) self.assertTrue(tile.filter_pattern_config != '{}') tile()
def test_querylisting_results(self): page1 = api.content.create(type='Document', id='page1', container=self.portal, subject=('foobar', ), title='Foobar') page2 = api.content.create(type='Document', id='page2', container=self.portal, subject=('foobar', ), title='Foobar') page3 = api.content.create(type='Document', id='page3', container=self.portal, subject=('foobar', 'foobar2'), title='Foobar') page4 = api.content.create(type='Document', id='page4', container=self.portal, subject=('foobar', 'foobar2'), title='Foobar') data = { 'query': [{ 'i': 'Subject', 'o': 'plone.app.querystring.operation.list.contains', 'v': 'foobar2' }], 'available_tags': ('foobar2', ) } for item in [page1, page2, page3, page4]: api.content.transition(obj=item, to_state='published') tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', data) self.assertEqual(tile.results()['total'], 2) self.request.form.update({'Subject': 'foobar'}) tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', data) self.assertEqual(tile.results()['total'], 4) name = self.prefix + 'querylisting' page = render_tile(self.request, self.portal, name, data) self.assertTrue('Foobar' in page)
def test_querylisting_unicode_issue(self): tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', {}) # should not cause errors... self.request.form.update({'Title': u'santas ure�a'}) self.assertTrue(tile.filter_pattern_config != '{}') tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', {}) self.request.form.update({'Title': 'santas ure�a'}) self.assertTrue(tile.filter_pattern_config != '{}') tile = get_tile(self.request, self.portal, 'castle.cms.querylisting', {}) self.request.form.update({ # form data can be list OR str 'Subject': ['one', 'two'] }) self.assertTrue(tile.filter_pattern_config != '{}')