tests: make i18n tests independant (#86736)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Valentin Deniaud 2024-02-08 16:22:14 +01:00
parent b63bc74a4d
commit 54e78443a6
2 changed files with 13 additions and 21 deletions

View File

@ -32,6 +32,14 @@ def pub():
TranslatableMessage.do_table() # update table with selected languages
TranslatableMessage.wipe()
Workflow.wipe()
FormDef.wipe()
BlockDef.wipe()
Category.wipe()
CardDef.wipe()
MailTemplate.wipe()
return pub
@ -180,9 +188,6 @@ def test_i18n_page(pub):
def test_i18n_export(pub):
create_superuser(pub)
Workflow.wipe()
BlockDef.wipe()
TranslatableMessage.wipe()
formdef = FormDef()
formdef.name = 'test title'
@ -234,9 +239,6 @@ def test_i18n_export(pub):
def test_i18n_import(pub):
create_superuser(pub)
Workflow.wipe()
BlockDef.wipe()
TranslatableMessage.wipe()
formdef = FormDef()
formdef.name = 'test title'
@ -334,9 +336,6 @@ def test_i18n_import(pub):
def test_i18n_pagination(pub):
create_superuser(pub)
Workflow.wipe()
BlockDef.wipe()
TranslatableMessage.wipe()
formdef = FormDef()
formdef.name = 'test title'
@ -351,22 +350,15 @@ def test_i18n_pagination(pub):
resp = resp.click('Go to multilinguism page')
# check page limit
assert resp.pyquery('#page-links a').text() == '1 2 3 4 5 6 10 50 100'
assert resp.pyquery('#page-links a').text() == '1 2 3 4 5 10 50 100'
resp = resp.click('50')
assert resp.pyquery('#page-links a').text() == '1 2 3 10 20 100'
assert resp.pyquery('#page-links a').text() == '1 2 10 20 100'
resp = resp.click('20')
resp = resp.click('3')
assert 'offset=40' in resp.request.url
def test_i18n_mark_as_non_translatabe(pub):
TranslatableMessage.wipe()
Workflow.wipe()
FormDef.wipe()
BlockDef.wipe()
Category.wipe()
CardDef.wipe()
MailTemplate.wipe()
create_superuser(pub)
workflow = Workflow(name='workflow')
workflow.add_status('First Status')

View File

@ -61,9 +61,6 @@ class I18nDirectory(Directory):
if not get_publisher().has_i18n_enabled():
raise errors.TraversalError()
if TranslatableMessage.count() == 0:
return self.scan()
get_response().set_title(_('Multilinguism'))
get_response().breadcrumb.append(('i18n/', _('Multilinguism')))
@ -77,6 +74,9 @@ class I18nDirectory(Directory):
r += htmltext('</div>')
return r.getvalue()
if TranslatableMessage.count() == 0:
return self.scan()
criterias = []
criterias.append(Equal('translatable', not (bool(get_request().form.get('non_translatable')))))
if get_request().form.get('q'):