Projet

Général

Profil

0001-workflows-do-not-record-missing-wscall-target-status.patch

Frédéric Péters, 23 janvier 2022 17:47

Télécharger (4,81 ko)

Voir les différences:

Subject: [PATCH] workflows: do not record missing wscall target status errors
 in graph (#60831)

 tests/admin_pages/test_workflow.py | 14 ++------------
 tests/workflow/test_all.py         | 11 ++++++++++-
 wcs/wf/wscall.py                   | 20 +++++++++++---------
 3 files changed, 23 insertions(+), 22 deletions(-)
tests/admin_pages/test_workflow.py
2945 2945
    app.get('/backoffice/workflows/%s/' % workflow.id)
2946 2946
    assert pub.loggederror_class.count() == 0
2947 2947

  
2948
    # delete foo status
2948
    # delete foo status, make sure rendering the graph doesn't record errors
2949 2949
    del workflow.possible_status[1]
2950 2950
    workflow.store()
2951 2951
    app.get('/backoffice/workflows/%s/' % workflow.id)
2952
    assert pub.loggederror_class.count() == 1
2953
    error = pub.loggederror_class.select()[0]
2954
    assert (
2955
        error.tech_id
2956
        == '%s-reference-to-invalid-status-in-workflow-foo-status-baz-item-webservice' % workflow.id
2957
    )
2958
    assert error.formdef_id is None
2959
    assert error.formdef_class is None
2960
    assert error.workflow_id == workflow.id
2961
    assert error.summary == 'reference to invalid status in workflow foo, status baz, item Webservice'
2962
    assert error.occurences_count == 5
2952
    assert pub.loggederror_class.count() == 0
2963 2953

  
2964 2954

  
2965 2955
def test_workflows_wscall_empty_param_values(pub):
tests/workflow/test_all.py
1585 1585
    assert 'to-role-or-submitter.txt' in display_parts()[6]
1586 1586

  
1587 1587

  
1588
def test_webservice_call(http_requests, pub):
1588
def test_webservice_call(http_requests, two_pubs):
1589
    pub = two_pubs
1589 1590
    pub.substitutions.feed(MockSubstitutionVariables())
1590 1591

  
1591 1592
    wf = Workflow(name='wf1')
......
1777 1778
    with pytest.raises(AbortActionException):
1778 1779
        item.perform(formdata)
1779 1780
    assert formdata.status == 'wf-sterr'
1781

  
1782
    if pub.is_using_postgresql():
1783
        pub.loggederror_class.wipe()
1780 1784
    item.action_on_5xx = 'stdeleted'  # removed status
1781 1785
    formdata.status = 'wf-st1'
1782 1786
    formdata.store()
1783 1787
    with pytest.raises(AbortActionException):
1784 1788
        item.perform(formdata)
1785 1789
    assert formdata.status == 'wf-st1'  # unknown status acts like :stop
1790
    if pub.is_using_postgresql():
1791
        assert pub.loggederror_class.count() == 1
1792
        error = pub.loggederror_class.select()[0]
1793
        assert 'reference-to-invalid-status-stdeleted-in-workflow' in error.tech_id
1794
        assert error.occurences_count == 1
1786 1795

  
1787 1796
    item = WebserviceCallStatusItem()
1788 1797
    item.url = 'http://remote.example.net/xml'
wcs/wf/wscall.py
530 530
        # do not return anything as target status are accessory
531 531
        return None
532 532

  
533
    def get_target_status(self):
533
    def get_target_status(self, formdata=None):
534 534
        # always return self status as a target so it's included in the
535 535
        # workflow visualisation as a "normal" action, in addition to
536 536
        # jumps related to error handling.
......
548 548
            try:
549 549
                target = self.parent.parent.get_status(value)
550 550
            except KeyError:
551
                message = _(
552
                    'reference to invalid status in workflow %(workflow)s, status %(status)s, item %(item)s'
553
                ) % {
554
                    'workflow': self.parent.parent.name,
555
                    'status': self.parent.name,
556
                    'item': self.description,
557
                }
558
                get_publisher().record_error(message, workflow=self.parent.parent)
551
                if formdata:
552
                    # do not log when rendering the workflow diagram
553
                    message = _(
554
                        'reference to invalid status in workflow %(workflow)s, status %(status)s, item %(item)s'
555
                    ) % {
556
                        'workflow': self.parent.parent.name,
557
                        'status': self.parent.name,
558
                        'item': self.description,
559
                    }
560
                    get_publisher().record_error(message, workflow=self.parent.parent)
559 561
                continue
560 562
            targets.append(target)
561 563
        return targets
562
-