depreciation: rename DeprecationsScanAfterJob (#72093)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2024-03-04 17:23:41 +01:00 committed by Lauréline Guérin
parent b4c4181cde
commit 3477ee2f29
8 changed files with 36 additions and 36 deletions

View File

@ -7,7 +7,7 @@ import pytest
from quixote.http_request import Upload as QuixoteUpload
from wcs import fields
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
from wcs.blocks import BlockDef, BlockdefImportError
from wcs.carddef import CardDef
from wcs.data_sources import NamedDataSource, NamedDataSourceImportError
@ -293,7 +293,7 @@ def test_deprecations_choice_label(pub):
accept = st0.add_action('choice', id='_choice')
accept.label = '[test] action'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert not job.report_lines
@ -305,7 +305,7 @@ def test_deprecations_skip_invalid_ezt(pub):
display = st0.add_action('displaymsg')
display.message = 'message with invalid [if-any] ezt'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert not job.report_lines
@ -316,19 +316,19 @@ def test_deprecations_ignore_ezt_looking_tag(pub):
sendmail = st0.add_action('sendmail')
sendmail.subject = '[REMINDER] your appointment'
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert not job.report_lines
sendmail.subject = '[reminder]'
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert job.report_lines
sendmail.subject = '[if-any plop]test[end]'
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert job.report_lines
@ -397,7 +397,7 @@ def test_deprecations_document_models(pub):
export_to2.by = ['_submitter']
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
assert job.report_lines == [
{
@ -446,7 +446,7 @@ def test_deprecations_inspect_pages(pub):
display.message = 'message with [ezt] info'
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
create_superuser(pub)
@ -485,7 +485,7 @@ def test_deprecations_inspect_pages(pub):
display.message = 'message with {{django}} info'
workflow.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
resp = app.get(formdef.get_admin_url() + 'inspect')
@ -506,7 +506,7 @@ def test_deprecations_inspect_pages_old_format(pub):
]
formdef.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.execute()
with open(os.path.join(pub.app_dir, 'deprecations.json')) as f:
@ -566,32 +566,32 @@ def test_deprecations_on_import(pub):
mail_template.body = 'plop [ezt] plop'
mail_template.store()
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(formdef)
formdef_xml = formdef.export_to_xml()
FormDef.import_from_xml_tree(formdef_xml)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(blockdef)
blockdef_xml = blockdef.export_to_xml()
BlockDef.import_from_xml_tree(blockdef_xml)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(workflow)
workflow_xml = workflow.export_to_xml()
Workflow.import_from_xml_tree(workflow_xml)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(data_source)
data_source_xml = data_source.export_to_xml()
NamedDataSource.import_from_xml_tree(data_source_xml)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(wscall)
wscall_xml = wscall.export_to_xml()
NamedWsCall.import_from_xml_tree(wscall_xml)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(mail_template)
mail_template_xml = mail_template.export_to_xml()
MailTemplate.import_from_xml_tree(mail_template_xml)
@ -602,7 +602,7 @@ def test_deprecations_on_import(pub):
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
pub.site_options.write(fd)
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
with pytest.raises(DeprecatedElementsDetected) as excinfo:
job.check_deprecated_elements_in_object(formdef)
assert str(excinfo.value) == 'Python expression detected'
@ -610,7 +610,7 @@ def test_deprecations_on_import(pub):
FormDef.import_from_xml_tree(formdef_xml)
assert str(excinfo.value) == 'Python expression detected'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
with pytest.raises(DeprecatedElementsDetected) as excinfo:
job.check_deprecated_elements_in_object(blockdef)
assert str(excinfo.value) == 'Python expression detected'
@ -618,7 +618,7 @@ def test_deprecations_on_import(pub):
BlockDef.import_from_xml_tree(blockdef_xml)
assert str(excinfo.value) == 'Python expression detected'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
with pytest.raises(DeprecatedElementsDetected) as excinfo:
job.check_deprecated_elements_in_object(workflow)
assert str(excinfo.value) == 'Python expression detected'
@ -626,7 +626,7 @@ def test_deprecations_on_import(pub):
Workflow.import_from_xml_tree(workflow_xml)
assert str(excinfo.value) == 'Python expression detected'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
with pytest.raises(DeprecatedElementsDetected) as excinfo:
job.check_deprecated_elements_in_object(data_source)
assert str(excinfo.value) == 'Python expression detected'
@ -634,7 +634,7 @@ def test_deprecations_on_import(pub):
NamedDataSource.import_from_xml_tree(data_source_xml)
assert str(excinfo.value) == 'Python expression detected'
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
with pytest.raises(DeprecatedElementsDetected) as excinfo:
job.check_deprecated_elements_in_object(wscall)
assert str(excinfo.value) == 'Python expression detected'
@ -643,6 +643,6 @@ def test_deprecations_on_import(pub):
assert str(excinfo.value) == 'Python expression detected'
# no python expressions
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
job.check_deprecated_elements_in_object(mail_template)
MailTemplate.import_from_xml_tree(mail_template_xml)

View File

@ -73,7 +73,7 @@ class DeprecationsDirectory(Directory):
def scan(self):
job = get_response().add_after_job(
DeprecationsScanAfterJob(
DeprecationsScan(
label=_('Scanning for deprecations'),
user_id=get_request().user.id,
return_url='/backoffice/studio/deprecations/',
@ -134,7 +134,7 @@ class DeprecationsDirectory(Directory):
}
class DeprecationsScanAfterJob(AfterJob):
class DeprecationsScan(AfterJob):
def done_action_url(self):
return self.kwargs['return_url']

View File

@ -205,7 +205,7 @@ class BlockDef(StorableObject):
def import_from_xml_tree(
cls, tree, include_id=False, check_datasources=True, check_deprecated=True, **kwargs
):
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
blockdef = cls()
if tree.find('name') is None or not tree.find('name').text:
@ -290,7 +290,7 @@ class BlockDef(StorableObject):
if check_deprecated:
# check for deprecated elements
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
try:
job.check_deprecated_elements_in_object(blockdef)
except DeprecatedElementsDetected as e:

View File

@ -918,7 +918,7 @@ class NamedDataSource(XmlStorableObject):
@classmethod
def import_from_xml_tree(cls, tree, include_id=False, check_deprecated=True, **kwargs):
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
data_source = super().import_from_xml_tree(
tree, include_id=include_id, check_deprecated=check_deprecated, **kwargs
@ -927,7 +927,7 @@ class NamedDataSource(XmlStorableObject):
if check_deprecated:
# check for deprecated elements
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
try:
job.check_deprecated_elements_in_object(data_source)
except DeprecatedElementsDetected as e:

View File

@ -1508,7 +1508,7 @@ class FormDef(StorableObject):
check_datasources=True,
check_deprecated=True,
):
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
from wcs.carddef import CardDef
formdef = cls()
@ -1726,7 +1726,7 @@ class FormDef(StorableObject):
if check_deprecated:
# check for deprecated elements
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
try:
job.check_deprecated_elements_in_object(formdef)
except DeprecatedElementsDetected as e:

View File

@ -183,9 +183,9 @@ class WcsPublisher(QommonPublisher):
formdef.register_cronjobs()
def update_deprecations_report(self, **kwargs):
from .backoffice.deprecations import DeprecationsScanAfterJob
from .backoffice.deprecations import DeprecationsScan
DeprecationsScanAfterJob().execute()
DeprecationsScan().execute()
def has_postgresql_config(self):
return bool(self.cfg.get('postgresql', {}))

View File

@ -1255,7 +1255,7 @@ class Workflow(StorableObject):
def import_from_xml_tree(
cls, tree, include_id=False, snapshot=False, check_datasources=True, check_deprecated=True
):
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
workflow = cls()
if tree.find('name') is None or not tree.find('name').text:
@ -1370,7 +1370,7 @@ class Workflow(StorableObject):
if check_deprecated:
# check for deprecated elements
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
try:
job.check_deprecated_elements_in_object(workflow)
except DeprecatedElementsDetected as e:

View File

@ -286,7 +286,7 @@ class NamedWsCall(XmlStorableObject):
@classmethod
def import_from_xml_tree(cls, tree, include_id=False, check_deprecated=True, **kwargs):
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScanAfterJob
from wcs.backoffice.deprecations import DeprecatedElementsDetected, DeprecationsScan
wscall = super().import_from_xml_tree(
tree, include_id=include_id, check_deprecated=check_deprecated, **kwargs
@ -294,7 +294,7 @@ class NamedWsCall(XmlStorableObject):
if check_deprecated:
# check for deprecated elements
job = DeprecationsScanAfterJob()
job = DeprecationsScan()
try:
job.check_deprecated_elements_in_object(wscall)
except DeprecatedElementsDetected as e: