mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-09 18:14:09 +02:00
Use parametrize for FTS test
This commit is contained in:
parent
2dca2210d9
commit
42440d6345
1 changed files with 26 additions and 26 deletions
|
|
@ -180,32 +180,32 @@ def test_populate_fts_escape_table_names(fresh_db):
|
||||||
] == list(table.search("usa"))
|
] == list(table.search("usa"))
|
||||||
|
|
||||||
|
|
||||||
def test_fts_tokenize(fresh_db):
|
@pytest.mark.parametrize("fts_version", ("4", "5"))
|
||||||
for fts_version in ("4", "5"):
|
def test_fts_tokenize(fresh_db, fts_version):
|
||||||
table_name = "searchable_{}".format(fts_version)
|
table_name = "searchable_{}".format(fts_version)
|
||||||
table = fresh_db[table_name]
|
table = fresh_db[table_name]
|
||||||
table.insert_all(search_records)
|
table.insert_all(search_records)
|
||||||
# Test without porter stemming
|
# Test without porter stemming
|
||||||
table.enable_fts(
|
table.enable_fts(
|
||||||
["text", "country"],
|
["text", "country"],
|
||||||
fts_version="FTS{}".format(fts_version),
|
fts_version="FTS{}".format(fts_version),
|
||||||
)
|
)
|
||||||
assert [] == list(table.search("bite"))
|
assert [] == list(table.search("bite"))
|
||||||
# Test WITH stemming
|
# Test WITH stemming
|
||||||
table.disable_fts()
|
table.disable_fts()
|
||||||
table.enable_fts(
|
table.enable_fts(
|
||||||
["text", "country"],
|
["text", "country"],
|
||||||
fts_version="FTS{}".format(fts_version),
|
fts_version="FTS{}".format(fts_version),
|
||||||
tokenize="porter",
|
tokenize="porter",
|
||||||
)
|
)
|
||||||
rows = list(table.search("bite", order_by="rowid"))
|
rows = list(table.search("bite", order_by="rowid"))
|
||||||
assert len(rows) == 1
|
assert len(rows) == 1
|
||||||
assert {
|
assert {
|
||||||
"rowid": 2,
|
"rowid": 2,
|
||||||
"text": "racoons are biting trash pandas",
|
"text": "racoons are biting trash pandas",
|
||||||
"country": "USA",
|
"country": "USA",
|
||||||
"not_searchable": "bar",
|
"not_searchable": "bar",
|
||||||
}.items() <= rows[0].items()
|
}.items() <= rows[0].items()
|
||||||
|
|
||||||
|
|
||||||
def test_optimize_fts(fresh_db):
|
def test_optimize_fts(fresh_db):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue