Compare commits

..

1 Commits

Author SHA1 Message Date
Pierre Ducroquet fc6e252770 sql: test purge of search tokens (#86527)
gitea/wcs/pipeline/head There was a failure building this commit Details
2024-03-05 11:34:31 +01:00
2 changed files with 14 additions and 11 deletions

View File

@ -1184,39 +1184,42 @@ def test_sql_criteria_fts(pub):
def test_search_tokens_purge(pub):
conn, cur = sql.get_connection_and_cursor()
_, cur = sql.get_connection_and_cursor()
# purge garbage from other tests
sql.purge_obsolete_search_tokens()
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
start = cur.fetchone()[0]
# define a new table
test_formdef = FormDef()
test_formdef.name = 'table select fts tokens'
test_formdef.name = 'tableSelectFTStokens'
test_formdef.fields = [fields.StringField(id='3', label='string')]
test_formdef.store()
data_class = test_formdef.data_class(mode='sql')
cur.execute("SELECT count(*) FROM wcs_search_tokens;")
assert cur.fetchone()[0] == 116
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
assert cur.fetchone()[0] == start+1
t = data_class()
t.data = {'3': 'foofortokensofcourse'}
t.just_created()
t.store()
cur.execute("SELECT count(*) FROM wcs_search_tokens;")
assert cur.fetchone()[0] == 117
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
assert cur.fetchone()[0] == start+2
t.data = {'3': 'chaussettefortokensofcourse'}
t.store()
cur.execute("SELECT count(*) FROM wcs_search_tokens;")
assert cur.fetchone()[0] == 118
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
assert cur.fetchone()[0] == start+3
sql.purge_obsolete_search_tokens()
cur.execute("SELECT count(*) FROM wcs_search_tokens;")
assert cur.fetchone()[0] == 117
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
assert cur.fetchone()[0] == start+2
def table_exists(cur, table_name):

View File

@ -40,7 +40,7 @@ allowlist_externals =
./getlasso3.sh
commands =
./getlasso3.sh
py.test {posargs:-v {env:COVERAGE:} --numprocesses={env:NUMPROCESSES:1} --dist loadfile --junitxml=junit-{envname}.xml tests/test_sql.py}
py.test {posargs:-v {env:COVERAGE:} --numprocesses={env:NUMPROCESSES:1} --dist loadfile --junitxml=junit-{envname}.xml tests/}
codestyle: pre-commit run --all-files --show-diff-on-failure
[testenv:pylint]