fix: test: exp argument test_search_by_tag_query
This commit is contained in:
parent
fc4f6bff6e
commit
fc9558e6f3
@ -1107,7 +1107,7 @@ def test_update_rec_exec_arg(caplog, kwargs, exp_query, exp_query_p37, exp_argum
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'tags_to_search, exp_query, exp_query_p37, exp_arguments',
|
'tags_to_search, exp_query, exp_query_p37, exp_arguments, exp_arguments_p37',
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'tag1, tag2',
|
'tag1, tag2',
|
||||||
@ -1117,7 +1117,8 @@ def test_update_rec_exec_arg(caplog, kwargs, exp_query, exp_query_p37, exp_argum
|
|||||||
"FROM (SELECT *, CASE WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END + CASE "
|
"FROM (SELECT *, CASE WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END + CASE "
|
||||||
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END AS score "
|
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END AS score "
|
||||||
"FROM bookmarks WHERE score > 0 ORDER BY score DESC)",
|
"FROM bookmarks WHERE score > 0 ORDER BY score DESC)",
|
||||||
[',tag1,', ',tag2,']
|
[',tag1,', ',tag2,'],
|
||||||
|
None
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'tag2+tag2,tag3, tag4',
|
'tag2+tag2,tag3, tag4',
|
||||||
@ -1128,30 +1129,35 @@ def test_update_rec_exec_arg(caplog, kwargs, exp_query, exp_query_p37, exp_argum
|
|||||||
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END + CASE "
|
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END + CASE "
|
||||||
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END AS score "
|
"WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END AS score "
|
||||||
"FROM bookmarks WHERE score > 0 ORDER BY score DESC)",
|
"FROM bookmarks WHERE score > 0 ORDER BY score DESC)",
|
||||||
[',tag1+tag2,', ',tag3,', ',tag4,']
|
[',tag1+tag2,', ',tag3,', ',tag4,'],
|
||||||
|
[',tag2+tag2,', ',tag3,', ',tag4,']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'tag1 + tag2+tag3',
|
'tag1 + tag2+tag3',
|
||||||
"SELECT id, url, metadata, tags, desc FROM bookmarks WHERE tags LIKE '%' || ? || '%' "
|
"SELECT id, url, metadata, tags, desc FROM bookmarks WHERE tags LIKE '%' || ? || '%' "
|
||||||
"AND tags LIKE '%' || ? || '%' ORDER BY id ASC",
|
"AND tags LIKE '%' || ? || '%' ORDER BY id ASC",
|
||||||
None,
|
None,
|
||||||
[',tag1,', ',tag2+tag3,']
|
[',tag1,', ',tag2+tag3,'],
|
||||||
|
None
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'tag1-tag2 + tag 3 - tag4',
|
'tag1-tag2 + tag 3 - tag4',
|
||||||
"SELECT id, url, metadata, tags, desc FROM bookmarks WHERE (tags LIKE '%' || ? || '%' "
|
"SELECT id, url, metadata, tags, desc FROM bookmarks WHERE (tags LIKE '%' || ? || '%' "
|
||||||
"AND tags LIKE '%' || ? || '%' ) AND tags NOT REGEXP ? ORDER BY id ASC",
|
"AND tags LIKE '%' || ? || '%' ) AND tags NOT REGEXP ? ORDER BY id ASC",
|
||||||
None,
|
None,
|
||||||
[',tag1-tag2,', ',tag 3,', ',tag4,']
|
[',tag1-tag2,', ',tag 3,', ',tag4,'],
|
||||||
|
None
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_search_by_tag_query(caplog, tags_to_search, exp_query, exp_query_p37, exp_arguments):
|
def test_search_by_tag_query(caplog, tags_to_search, exp_query, exp_query_p37, exp_arguments, exp_arguments_p37):
|
||||||
"""test that the correct query and argments are constructed"""
|
"""test that the correct query and argments are constructed"""
|
||||||
if (sys.version_info.major, sys.version_info.minor) == (3, 7):
|
if (sys.version_info.major, sys.version_info.minor) == (3, 7):
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
if exp_query_p37:
|
if exp_query_p37:
|
||||||
exp_query = exp_query_p37
|
exp_query = exp_query_p37
|
||||||
|
if exp_arguments_p37:
|
||||||
|
exp_arguments = exp_arguments_p37
|
||||||
bdb = BukuDb()
|
bdb = BukuDb()
|
||||||
bdb.search_by_tag(tags_to_search)
|
bdb.search_by_tag(tags_to_search)
|
||||||
exp_log = 'query: "{}", args: {}'.format(exp_query, exp_arguments)
|
exp_log = 'query: "{}", args: {}'.format(exp_query, exp_arguments)
|
||||||
|
Loading…
Reference in New Issue
Block a user