"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test_indexer.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

test_indexer.py  (roundup-1.6.1):test_indexer.py  (roundup-2.0.0)
skipping to change at line 28 skipping to change at line 28
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
import os, unittest, shutil import os, unittest, shutil
import pytest import pytest
from roundup.backends import get_backend, have_backend from roundup.backends import get_backend, have_backend
from roundup.backends.indexer_rdbms import Indexer from roundup.backends.indexer_rdbms import Indexer
# borrow from other tests # borrow from other tests
from db_test_base import setupSchema, config from .db_test_base import setupSchema, config
from .test_postgresql import postgresqlOpener, skip_postgresql from .test_postgresql import postgresqlOpener, skip_postgresql
from .test_mysql import mysqlOpener, skip_mysql from .test_mysql import mysqlOpener, skip_mysql
from test_sqlite import sqliteOpener from .test_sqlite import sqliteOpener
try: try:
import xapian import xapian
skip_xapian = lambda func, *args, **kwargs: func skip_xapian = lambda func, *args, **kwargs: func
except ImportError: except ImportError:
# FIX: workaround for a bug in pytest.mark.skip(): # FIX: workaround for a bug in pytest.mark.skip():
# https://github.com/pytest-dev/pytest/issues/568 # https://github.com/pytest-dev/pytest/issues/568
from .pytest_patcher import mark_class from .pytest_patcher import mark_class
skip_xapian = mark_class(pytest.mark.skip( skip_xapian = mark_class(pytest.mark.skip(
"Skipping Xapian indexer tests: 'xapian' not installed")) "Skipping Xapian indexer tests: 'xapian' not installed"))
skipping to change at line 107 skipping to change at line 107
self.dex.add_text(('test', '1', 'foo'), 'a the hello world') self.dex.add_text(('test', '1', 'foo'), 'a the hello world')
self.dex.add_text(('test', '2', 'foo'), 'blah blah the world') self.dex.add_text(('test', '2', 'foo'), 'blah blah the world')
self.assertSeqEqual(self.dex.find(['world']), [('test', '1', 'foo'), self.assertSeqEqual(self.dex.find(['world']), [('test', '1', 'foo'),
('test', '2', 'foo')]) ('test', '2', 'foo')])
self.dex.add_text(('test', '1', 'foo'), '') self.dex.add_text(('test', '1', 'foo'), '')
self.assertSeqEqual(self.dex.find(['world']), [('test', '2', 'foo')]) self.assertSeqEqual(self.dex.find(['world']), [('test', '2', 'foo')])
def test_stopwords(self): def test_stopwords(self):
"""Test that we can find a text with a stopword in it.""" """Test that we can find a text with a stopword in it."""
stopword = "with" stopword = "with"
self.assert_(self.dex.is_stopword(stopword.upper())) self.assertTrue(self.dex.is_stopword(stopword.upper()))
self.dex.add_text(('test', '1', 'bar'), '%s hello world' % stopword) self.dex.add_text(('test', '1', 'bar'), '%s hello world' % stopword)
self.dex.add_text(('test', '2', 'bar'), 'blah a %s world' % stopword) self.dex.add_text(('test', '2', 'bar'), 'blah a %s world' % stopword)
self.dex.add_text(('test', '3', 'bar'), 'blah Blub river') self.dex.add_text(('test', '3', 'bar'), 'blah Blub river')
self.dex.add_text(('test', '4', 'bar'), 'blah river %s' % stopword) self.dex.add_text(('test', '4', 'bar'), 'blah river %s' % stopword)
self.assertSeqEqual(self.dex.find(['with','world']), self.assertSeqEqual(self.dex.find(['with','world']),
[('test', '1', 'bar'), [('test', '1', 'bar'),
('test', '2', 'bar')]) ('test', '2', 'bar')])
def test_extremewords(self): def test_extremewords(self):
"""Testing too short or too long words.""" """Testing too short or too long words."""
short = "b" short = "b"
skipping to change at line 160 skipping to change at line 160
for k in 'aaaa', 'aaa', 'bbbb', 'bbb': for k in 'aaaa', 'aaa', 'bbbb', 'bbb':
self.assertSeqEqual(self.dex.find([k]), self.assertSeqEqual(self.dex.find([k]),
[('test', '1', 'a'), ('test', '2', 'a')]) [('test', '1', 'a'), ('test', '2', 'a')])
def test_manyresults(self): def test_manyresults(self):
"""Test if searches find many results.""" """Test if searches find many results."""
for i in range(123): for i in range(123):
self.dex.add_text(('test', str(i), 'many'), 'many') self.dex.add_text(('test', str(i), 'many'), 'many')
self.assertEqual(len(self.dex.find(['many'])), 123) self.assertEqual(len(self.dex.find(['many'])), 123)
def test_unicode(self):
"""Test with unicode words. see:
https://issues.roundup-tracker.org/issue1344046"""
russian=u'\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\
u0441\u0442Spr\xfcnge'
german=u'Spr\xfcnge'
self.dex.add_text(('test', '1', 'a'), german )
self.dex.add_text(('test', '2', 'a'), russian + u' ' + german )
self.assertSeqEqual(self.dex.find([ u'Spr\xfcnge']),
[('test', '1', 'a'), ('test', '2', 'a')])
self.assertSeqEqual(self.dex.find([u'\u0440\u0443\u0441\u0441\u043a\u043
8\u0439']),
[('test', '2', 'a')])
def tearDown(self): def tearDown(self):
shutil.rmtree('test-index') shutil.rmtree('test-index')
@skip_whoosh @skip_whoosh
class WhooshIndexerTest(IndexerTest): class WhooshIndexerTest(IndexerTest):
def setUp(self): def setUp(self):
if os.path.exists('test-index'): if os.path.exists('test-index'):
shutil.rmtree('test-index') shutil.rmtree('test-index')
os.mkdir('test-index') os.mkdir('test-index')
from roundup.backends.indexer_whoosh import Indexer from roundup.backends.indexer_whoosh import Indexer
 End of changes. 4 change blocks. 
3 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)