Projet

Général

Profil

0001-workflows-allow-negative-values-in-global-trigger-de.patch

Frédéric Péters, 09 juillet 2018 21:08

Télécharger (2,23 ko)

Voir les différences:

Subject: [PATCH] workflows: allow negative values in global trigger delay
 (#25156)

 tests/test_admin_pages.py | 14 +++++++++++---
 wcs/workflows.py          |  3 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)
tests/test_admin_pages.py
2963 2963
    assert 'Timeout (not configured)' in resp.body
2964 2964

  
2965 2965
    resp = resp.click(href='triggers/%s/' % Workflow.get(workflow.id).global_actions[0].triggers[0].id, index=0)
2966
    resp.form['timeout'] = 'foobar'
2966
    for invalid_value in ('foobar', '-'):
2967
        resp.form['timeout'] = invalid_value
2968
        resp = resp.form.submit('submit')
2969
        assert 'wrong format' in resp.body
2970
    resp.form['timeout'] = ''
2967 2971
    resp = resp.form.submit('submit')
2968
    assert 'wrong format' in resp.body
2972
    assert 'required field' in resp.body
2969 2973
    resp.form['timeout'] = '3'
2970
    resp = resp.form.submit('submit')
2974
    resp = resp.form.submit('submit').follow()
2971 2975

  
2972 2976
    assert Workflow.get(workflow.id).global_actions[0].triggers[0].timeout == '3'
2973 2977

  
2978
    resp = resp.click(href='triggers/%s/' % Workflow.get(workflow.id).global_actions[0].triggers[0].id, index=0)
2979
    resp.form['timeout'] = '-2'
2980
    resp = resp.form.submit('submit').follow()
2981
    assert Workflow.get(workflow.id).global_actions[0].triggers[0].timeout == '-2'
2974 2982

  
2975 2983
def test_workflows_criticality_levels(pub):
2976 2984
    create_superuser(pub)
wcs/workflows.py
1038 1038

  
1039 1039
        form.add(ValidatedStringWidget, 'timeout', title=_('Timeout'),
1040 1040
                 value=self.timeout,
1041
                 regex=r'^\d*$',
1041
                 regex=r'^-?\d+$',
1042
                 required=True,
1042 1043
                 hint=_('Number of days, relative to anchor point.'))
1043 1044

  
1044 1045
        return form
1045
-