misc: fix grepping into blocks (#73615)

This commit is contained in:
Frédéric Péters 2023-01-19 20:38:34 +01:00 committed by Gitea
parent a264458bca
commit 92dac5eb8c
2 changed files with 19 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import pytest
from django.core.management import CommandError, call_command
import wcs.qommon.ctl
from wcs.blocks import BlockDef
from wcs.carddef import CardDef
from wcs.ctl.delete_tenant import CmdDeleteTenant
from wcs.ctl.management.commands.trigger_jumps import select_and_jump_formdata
@ -919,3 +920,20 @@ def test_grep_workflow_options(pub):
'http://example.net/backoffice/forms/1/workflow-variables',
'foo_bar',
)
def test_grep_block(pub):
FormDef.wipe()
BlockDef.wipe()
blockdef = BlockDef()
blockdef.name = 'Foo'
blockdef.fields = [StringField(type='string', id='1', label='bar', size='40', required=True)]
blockdef.store()
with mock.patch('wcs.ctl.management.commands.grep.Command.print_hit') as print_hit:
call_command('grep', '--domain', 'example.net', 'bar')
assert print_hit.call_args[0] == (
'http://example.net/backoffice/forms/blocks/%s/1/' % blockdef.id,
'bar',
)

View File

@ -73,7 +73,7 @@ class Command(TenantCommand):
if self.check_string(getattr(formdef, attr, None), url=url):
break
for value in (formdef.workflow_options or {}).values():
for value in (getattr(formdef, 'workflow_options', None) or {}).values():
if self.check_string(value, url=url + 'workflow-variables'):
break