Mercurial > p > roundup > code
annotate test/test_indexer.py @ 6588:91ab3e0ffcd0
Summary: Add test cases for sqlite fts
Add support for using the FTS5 full text query engine for sqlite.
Also stubbed out some sections for adding postgresql FTS support as
well.
Added nee indexer type native-fts. It is not selected by default. The
indexer=native is used if no indexer is set. This prevents an upgrade
from seeming to wipe out the native index if upgraded and
indexer=native is not explicitly set.
Docs updated. Also changed section headers to sentence case for the
current release notes.
Indexing backend can control if the full text search phrase is broken
into a list of words or passed intact. For backends with query
languages (sqlite and can be enabled for whoosh and xapian) we do not
want the phrase "tokenized" on whitespace.
This also updates the rdbms database version to version 7 to add FTS
table. I will be using the same version when I add postgresql. If
somebody runs this version on postgresql, they will have to manually
add the fts tables for postgresql if they want to use it.
Added a new renderError method to client. This allows errors to be
reported still using page.html rather than raw html. It also supports
templates for any error code. If no template for the error code
(e.g. 400) is found, the error in raw html with no page frame is
shown.
New IndexerQueryError exception to pass back message about query syntax
errors.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 23 Jan 2022 18:57:45 -0500 |
| parents | c26b9ce33ae3 |
| children | 39189dd94f2c |
| rev | line source |
|---|---|
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 # Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 # Permission is hereby granted, free of charge, to any person obtaining a copy |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 # of this software and associated documentation files (the "Software"), to deal |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 # in the Software without restriction, including without limitation the rights |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 # copies of the Software, and to permit persons to whom the Software is |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 # furnished to do so, subject to the following conditions: |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 # The above copyright notice and this permission notice shall be included in |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 # all copies or substantial portions of the Software. |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 # SOFTWARE. |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 import os, unittest, shutil |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
23 import pytest |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
24 from roundup.backends import get_backend, have_backend |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
25 from roundup.backends.indexer_rdbms import Indexer |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
26 |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
27 from roundup.cgi.exceptions import IndexerQueryError |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
28 |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
29 # borrow from other tests |
|
5388
d26921b851c3
Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5109
diff
changeset
|
30 from .db_test_base import setupSchema, config |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
31 from .test_postgresql import postgresqlOpener, skip_postgresql |
|
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
32 from .test_mysql import mysqlOpener, skip_mysql |
|
5388
d26921b851c3
Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5109
diff
changeset
|
33 from .test_sqlite import sqliteOpener |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
34 |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
35 try: |
|
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
36 import xapian |
|
5038
c977f3530944
Work-around for pytest.mark.skipif() bug
John Kristensen <john@jerrykan.com>
parents:
5037
diff
changeset
|
37 skip_xapian = lambda func, *args, **kwargs: func |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
38 except ImportError: |
|
5109
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
39 # FIX: workaround for a bug in pytest.mark.skip(): |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
40 # https://github.com/pytest-dev/pytest/issues/568 |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
41 from .pytest_patcher import mark_class |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
42 skip_xapian = mark_class(pytest.mark.skip( |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
43 "Skipping Xapian indexer tests: 'xapian' not installed")) |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
44 |
|
5096
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
45 try: |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
46 import whoosh |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
47 skip_whoosh = lambda func, *args, **kwargs: func |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
48 except ImportError: |
|
5109
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
49 # FIX: workaround for a bug in pytest.mark.skip(): |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
50 # https://github.com/pytest-dev/pytest/issues/568 |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
51 from .pytest_patcher import mark_class |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
52 skip_whoosh = mark_class(pytest.mark.skip( |
|
43a1f7fe39f5
Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents:
5105
diff
changeset
|
53 "Skipping Whoosh indexer tests: 'whoosh' not installed")) |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
54 |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
55 class db: |
|
3546
a4edd24c32be
test fixes and checking of indexer overwrites (xapian currently fails)
Richard Jones <richard@users.sourceforge.net>
parents:
3297
diff
changeset
|
56 class config(dict): |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
57 DATABASE = 'test-index' |
|
3546
a4edd24c32be
test fixes and checking of indexer overwrites (xapian currently fails)
Richard Jones <richard@users.sourceforge.net>
parents:
3297
diff
changeset
|
58 config = config() |
|
a4edd24c32be
test fixes and checking of indexer overwrites (xapian currently fails)
Richard Jones <richard@users.sourceforge.net>
parents:
3297
diff
changeset
|
59 config[('main', 'indexer_stopwords')] = [] |
|
6353
9d209d2b34ae
Add indexer_language to change stemmer for xapian FTS indexer
John Rouillard <rouilj@ieee.org>
parents:
5964
diff
changeset
|
60 config[('main', 'indexer_language')] = "english" |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
61 |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 class IndexerTest(unittest.TestCase): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 def setUp(self): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 if os.path.exists('test-index'): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 shutil.rmtree('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 os.mkdir('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 os.mkdir('test-index/files') |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
68 from roundup.backends.indexer_dbm import Indexer |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
69 self.dex = Indexer(db) |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 self.dex.load_index() |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
72 def assertSeqEqual(self, s1, s2): |
|
4102
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
73 # First argument is the db result we're testing, second is the |
|
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
74 # desired result. Some db results don't have iterable rows, so we |
|
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
75 # have to work around that. |
|
4015
6eec11b197aa
fix for indexer-test:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4008
diff
changeset
|
76 # Also work around some dbs not returning items in the expected |
|
4102
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
77 # order. |
|
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
78 s1 = list([tuple([r[n] for n in range(len(r))]) for r in s1]) |
|
4015
6eec11b197aa
fix for indexer-test:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4008
diff
changeset
|
79 s1.sort() |
|
4102
dcca66d56815
fix unit test compatibility
Richard Jones <richard@users.sourceforge.net>
parents:
4016
diff
changeset
|
80 if s1 != s2: |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
81 self.fail('contents of %r != %r'%(s1, s2)) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
82 |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 def test_basics(self): |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
84 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
85 self.dex.add_text(('test', '2', 'foo'), 'blah blah the world') |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
86 self.assertSeqEqual(self.dex.find(['world']), [('test', '1', 'foo'), |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
87 ('test', '2', 'foo')]) |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
88 self.assertSeqEqual(self.dex.find(['blah']), [('test', '2', 'foo')]) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
89 self.assertSeqEqual(self.dex.find(['blah', 'hello']), []) |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 |
|
3547
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
91 def test_change(self): |
|
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
92 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
93 self.dex.add_text(('test', '2', 'foo'), 'blah blah the world') |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
94 self.assertSeqEqual(self.dex.find(['world']), [('test', '1', 'foo'), |
|
3547
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
95 ('test', '2', 'foo')]) |
|
3546
a4edd24c32be
test fixes and checking of indexer overwrites (xapian currently fails)
Richard Jones <richard@users.sourceforge.net>
parents:
3297
diff
changeset
|
96 self.dex.add_text(('test', '1', 'foo'), 'a the hello') |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
97 self.assertSeqEqual(self.dex.find(['world']), [('test', '2', 'foo')]) |
|
3546
a4edd24c32be
test fixes and checking of indexer overwrites (xapian currently fails)
Richard Jones <richard@users.sourceforge.net>
parents:
3297
diff
changeset
|
98 |
|
3547
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
99 def test_clear(self): |
|
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
100 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
101 self.dex.add_text(('test', '2', 'foo'), 'blah blah the world') |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
102 self.assertSeqEqual(self.dex.find(['world']), [('test', '1', 'foo'), |
|
3547
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
103 ('test', '2', 'foo')]) |
|
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
104 self.dex.add_text(('test', '1', 'foo'), '') |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
105 self.assertSeqEqual(self.dex.find(['world']), [('test', '2', 'foo')]) |
|
3547
7728ee93efd2
fix reindexing in Xapian
Richard Jones <richard@users.sourceforge.net>
parents:
3546
diff
changeset
|
106 |
|
4251
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
107 def test_stopwords(self): |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
108 """Test that we can find a text with a stopword in it.""" |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
109 stopword = "with" |
|
5649
f8893e1cde0d
assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents:
5388
diff
changeset
|
110 self.assertTrue(self.dex.is_stopword(stopword.upper())) |
|
4251
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
111 self.dex.add_text(('test', '1', 'bar'), '%s hello world' % stopword) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
112 self.dex.add_text(('test', '2', 'bar'), 'blah a %s world' % stopword) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
113 self.dex.add_text(('test', '3', 'bar'), 'blah Blub river') |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
114 self.dex.add_text(('test', '4', 'bar'), 'blah river %s' % stopword) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
115 self.assertSeqEqual(self.dex.find(['with','world']), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
116 [('test', '1', 'bar'), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
117 ('test', '2', 'bar')]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
118 def test_extremewords(self): |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
119 """Testing too short or too long words.""" |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
120 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
121 # skip this for FTS test |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
122 if isinstance(self,sqliteFtsIndexerTest): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
123 pytest.skip("extremewords not tested for native FTS backends") |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
124 |
|
4251
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
125 short = "b" |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
126 long = "abcdefghijklmnopqrstuvwxyz" |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
127 self.dex.add_text(('test', '1', 'a'), '%s hello world' % short) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
128 self.dex.add_text(('test', '2', 'a'), 'blah a %s world' % short) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
129 self.dex.add_text(('test', '3', 'a'), 'blah Blub river') |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
130 self.dex.add_text(('test', '4', 'a'), 'blah river %s %s' |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
131 % (short, long)) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
132 self.assertSeqEqual(self.dex.find([short,'world', long, short]), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
133 [('test', '1', 'a'), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
134 ('test', '2', 'a')]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
135 self.assertSeqEqual(self.dex.find([long]),[]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
136 |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
137 # special test because some faulty code indexed length(word)>=2 |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
138 # but only considered length(word)>=3 to be significant |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
139 self.dex.add_text(('test', '5', 'a'), 'blah py %s %s' |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
140 % (short, long)) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
141 self.assertSeqEqual(self.dex.find(["py"]), [('test', '5', 'a')]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
142 |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
143 def test_casesensitity(self): |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
144 """Test if searches are case-in-sensitive.""" |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
145 self.dex.add_text(('test', '1', 'a'), 'aaaa bbbb') |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
146 self.dex.add_text(('test', '2', 'a'), 'aAaa BBBB') |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
147 self.assertSeqEqual(self.dex.find(['aaaa']), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
148 [('test', '1', 'a'), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
149 ('test', '2', 'a')]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
150 self.assertSeqEqual(self.dex.find(['BBBB']), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
151 [('test', '1', 'a'), |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
152 ('test', '2', 'a')]) |
|
2b1241daaa20
Added more indexer tests for stopwords, case-insensitity...
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4102
diff
changeset
|
153 |
|
4314
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
154 def test_wordsplitting(self): |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
155 """Test if word splitting works.""" |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
156 self.dex.add_text(('test', '1', 'a'), 'aaaa-aaa bbbb*bbb') |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
157 self.dex.add_text(('test', '2', 'a'), 'aaaA-aaa BBBB*BBB') |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
158 for k in 'aaaa', 'aaa', 'bbbb', 'bbb': |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
159 self.assertSeqEqual(self.dex.find([k]), |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
160 [('test', '1', 'a'), ('test', '2', 'a')]) |
|
b41a033bffcc
- add a small word-splitting test for the indexers...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4251
diff
changeset
|
161 |
|
4841
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
162 def test_manyresults(self): |
|
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
163 """Test if searches find many results.""" |
|
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
164 for i in range(123): |
|
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
165 self.dex.add_text(('test', str(i), 'many'), 'many') |
|
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
166 self.assertEqual(len(self.dex.find(['many'])), 123) |
|
3ff1a288fb9c
issue2550583, issue2550635 Do not limit results with Xapian indexer
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4570
diff
changeset
|
167 |
|
5960
0db2621b6fee
Add test for issue1344046 and maybe issue1195739
John Rouillard <rouilj@ieee.org>
parents:
5649
diff
changeset
|
168 def test_unicode(self): |
|
0db2621b6fee
Add test for issue1344046 and maybe issue1195739
John Rouillard <rouilj@ieee.org>
parents:
5649
diff
changeset
|
169 """Test with unicode words. see: |
|
0db2621b6fee
Add test for issue1344046 and maybe issue1195739
John Rouillard <rouilj@ieee.org>
parents:
5649
diff
changeset
|
170 https://issues.roundup-tracker.org/issue1344046""" |
|
5962
6137ea845438
Fix russian search/string
John Rouillard <rouilj@ieee.org>
parents:
5961
diff
changeset
|
171 russian=u'\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442Spr\xfcnge' |
|
5961
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
172 german=u'Spr\xfcnge' |
|
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
173 self.dex.add_text(('test', '1', 'a'), german ) |
|
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
174 self.dex.add_text(('test', '2', 'a'), russian + u' ' + german ) |
|
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
175 |
|
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
176 self.assertSeqEqual(self.dex.find([ u'Spr\xfcnge']), |
|
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
177 [('test', '1', 'a'), ('test', '2', 'a')]) |
|
5962
6137ea845438
Fix russian search/string
John Rouillard <rouilj@ieee.org>
parents:
5961
diff
changeset
|
178 self.assertSeqEqual(self.dex.find([u'\u0440\u0443\u0441\u0441\u043a\u0438\u0439']), |
|
5961
f6c58a7b535c
Add a russian string for unicode testing of indexer
John Rouillard <rouilj@ieee.org>
parents:
5960
diff
changeset
|
179 [('test', '2', 'a')]) |
|
5960
0db2621b6fee
Add test for issue1344046 and maybe issue1195739
John Rouillard <rouilj@ieee.org>
parents:
5649
diff
changeset
|
180 |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
181 def tearDown(self): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
182 shutil.rmtree('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
183 |
|
5096
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
184 @skip_whoosh |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
185 class WhooshIndexerTest(IndexerTest): |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
186 def setUp(self): |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
187 if os.path.exists('test-index'): |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
188 shutil.rmtree('test-index') |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
189 os.mkdir('test-index') |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
190 from roundup.backends.indexer_whoosh import Indexer |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
191 self.dex = Indexer(db) |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
192 def tearDown(self): |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5038
diff
changeset
|
193 shutil.rmtree('test-index') |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
194 |
|
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
195 @skip_xapian |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
196 class XapianIndexerTest(IndexerTest): |
|
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
197 def setUp(self): |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
198 if os.path.exists('test-index'): |
|
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
199 shutil.rmtree('test-index') |
|
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
200 os.mkdir('test-index') |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
201 from roundup.backends.indexer_xapian import Indexer |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
202 self.dex = Indexer(db) |
|
3295
a615cc230160
added Xapian indexer; replaces standard indexers if Xapian is available
Richard Jones <richard@users.sourceforge.net>
parents:
3078
diff
changeset
|
203 def tearDown(self): |
|
3297
8f7dc283bfa5
some more Xapian stuff (doc, test fixes)
Richard Jones <richard@users.sourceforge.net>
parents:
3295
diff
changeset
|
204 shutil.rmtree('test-index') |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
205 |
|
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
206 class RDBMSIndexerTest(object): |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
207 def setUp(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
208 # remove previous test, ignore errors |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
209 if os.path.exists(config.DATABASE): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
210 shutil.rmtree(config.DATABASE) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
211 self.db = self.module.Database(config, 'admin') |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
212 self.dex = Indexer(self.db) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
213 def tearDown(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
214 if hasattr(self, 'db'): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
215 self.db.close() |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
216 if os.path.exists(config.DATABASE): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
217 shutil.rmtree(config.DATABASE) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
218 |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
219 |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
220 @skip_postgresql |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
221 class postgresqlIndexerTest(postgresqlOpener, RDBMSIndexerTest, IndexerTest): |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
222 def setUp(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
223 postgresqlOpener.setUp(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
224 RDBMSIndexerTest.setUp(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
225 def tearDown(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
226 RDBMSIndexerTest.tearDown(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
227 postgresqlOpener.tearDown(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
228 |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
229 """ |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
230 @skip_postgresql |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
231 class postgresqlFtsIndexerTest(postgresqlOpener, RDBMSIndexerTest, IndexerTest): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
232 def setUp(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
233 postgresqlOpener.setUp(self) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
234 RDBMSIndexerTest.setUp(self) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
235 def tearDown(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
236 RDBMSIndexerTest.tearDown(self) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
237 postgresqlOpener.tearDown(self) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
238 """ |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
239 |
|
5036
380d8d8b30a3
Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents:
5033
diff
changeset
|
240 @skip_mysql |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
241 class mysqlIndexerTest(mysqlOpener, RDBMSIndexerTest, IndexerTest): |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
242 def setUp(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
243 mysqlOpener.setUp(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
244 RDBMSIndexerTest.setUp(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
245 def tearDown(self): |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
246 RDBMSIndexerTest.tearDown(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
247 mysqlOpener.tearDown(self) |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
248 |
|
5033
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
249 |
|
63c79c0992ae
Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents:
4841
diff
changeset
|
250 class sqliteIndexerTest(sqliteOpener, RDBMSIndexerTest, IndexerTest): |
|
4008
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
251 pass |
|
0bf9f8ae7d1b
fix bug introduced in 1.4.5 in RDBMS full-text indexing;
Richard Jones <richard@users.sourceforge.net>
parents:
3547
diff
changeset
|
252 |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
253 class sqliteFtsIndexerTest(sqliteOpener, RDBMSIndexerTest, IndexerTest): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
254 def setUp(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
255 RDBMSIndexerTest.setUp(self) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
256 from roundup.backends.indexer_sqlite_fts import Indexer |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
257 self.dex = Indexer(db) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
258 self.dex.db = self.db |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
259 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
260 def test_phrase_and_near(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
261 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
262 self.dex.add_text(('test', '2', 'foo'), 'helh blah blah the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
263 self.dex.add_text(('test', '3', 'foo'), 'blah hello the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
264 self.dex.add_text(('test', '4', 'foo'), 'hello blah blech the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
265 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
266 # test two separate words for sanity |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
267 self.assertSeqEqual(self.dex.find(['"hello" "world"']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
268 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
269 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
270 ('test', '4', 'foo') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
271 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
272 # now check the phrase |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
273 self.assertSeqEqual(self.dex.find(['"hello world"']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
274 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
275 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
276 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
277 # now check the phrase with near explicitly 0 intervening items |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
278 self.assertSeqEqual(self.dex.find(['NEAR(hello world, 0)']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
279 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
280 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
281 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
282 # now check the phrase with near explicitly 1 intervening item |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
283 self.assertSeqEqual(self.dex.find(['NEAR(hello world, 1)']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
284 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
285 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
286 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
287 # now check the phrase with near explicitly 3 intervening item |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
288 self.assertSeqEqual(self.dex.find(['NEAR(hello world, 3)']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
289 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
290 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
291 ('test', '4', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
292 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
293 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
294 def test_prefix(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
295 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
296 self.dex.add_text(('test', '2', 'foo'), 'helh blah blah the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
297 self.dex.add_text(('test', '3', 'foo'), 'blah hello the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
298 self.dex.add_text(('test', '4', 'foo'), 'hello blah blech the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
299 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
300 self.assertSeqEqual(self.dex.find(['hel*']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
301 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
302 ('test', '2', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
303 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
304 ('test', '4', 'foo') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
305 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
306 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
307 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
308 def test_bool_start(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
309 self.dex.add_text(('test', '1', 'foo'), 'a the hello world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
310 self.dex.add_text(('test', '2', 'foo'), 'helh blah blah the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
311 self.dex.add_text(('test', '3', 'foo'), 'blah hello the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
312 self.dex.add_text(('test', '4', 'foo'), 'hello blah blech the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
313 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
314 self.assertSeqEqual(self.dex.find(['hel* NOT helh NOT blech']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
315 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
316 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
317 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
318 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
319 self.assertSeqEqual(self.dex.find(['hel* NOT helh NOT blech OR the']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
320 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
321 ('test', '2', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
322 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
323 ('test', '4', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
324 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
325 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
326 self.assertSeqEqual(self.dex.find(['helh OR hello']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
327 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
328 ('test', '2', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
329 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
330 ('test', '4', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
331 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
332 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
333 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
334 self.assertSeqEqual(self.dex.find(['helh AND hello']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
335 []) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
336 # matches if line starts with hello |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
337 self.assertSeqEqual(self.dex.find(['^hello']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
338 [ |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
339 ('test', '4', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
340 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
341 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
342 self.assertSeqEqual(self.dex.find(['hello']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
343 [ |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
344 ('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
345 ('test', '3', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
346 ('test', '4', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
347 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
348 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
349 def test_query_errors(self): |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
350 """test query phrases that generate an error. Also test the |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
351 correction""" |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
352 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
353 self.dex.add_text(('test', '1', 'foo'), 'a the hello-world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
354 self.dex.add_text(('test', '2', 'foo'), 'helh blah blah the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
355 self.dex.add_text(('test', '3', 'foo'), 'blah hello the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
356 self.dex.add_text(('test', '4', 'foo'), 'hello blah blech the world') |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
357 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
358 # handle known error that roundup recognizes and tries to diagnose |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
359 with self.assertRaises(IndexerQueryError) as ctx: |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
360 self.dex.find(['the hello-world']) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
361 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
362 error = ( "Search failed. Try quoting any terms that include a '-' " |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
363 "and retry the search.") |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
364 self.assertEqual(str(ctx.exception), error) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
365 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
366 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
367 self.assertSeqEqual(self.dex.find(['the "hello-world"']), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
368 [('test', '1', 'foo'), |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
369 ]) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
370 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
371 # handle known error that roundup recognizes and tries to diagnose |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
372 with self.assertRaises(IndexerQueryError) as ctx: |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
373 self.dex.find(['hello world + ^the']) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
374 |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
375 error = 'Query error: syntax error near "^"' |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
376 self.assertEqual(str(ctx.exception), error) |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
377 |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
378 # vim: set filetype=python ts=4 sw=4 et si |
