Projet

Général

Profil

0001-workflow-ignore-empty-items-on-workflow-import-31823.patch

Nicolas Roche, 27 août 2019 16:57

Télécharger (2,23 ko)

Voir les différences:

Subject: [PATCH 1/4] workflow: ignore empty items on workflow import (#31823)

 tests/test_workflow_import.py | 13 +++++++++++--
 wcs/workflows.py              |  3 ++-
 2 files changed, 13 insertions(+), 3 deletions(-)
tests/test_workflow_import.py
42 42
    assert ET.tostring(export_to_indented_xml(wf)) == ET.tostring(export_to_indented_xml(wf2))
43 43
    return wf2
44 44

  
45
def assert_xml_import_export_works(wf, include_id=False):
46
    assert_import_export_works(wf)
47

  
48
    # import/export using xml format
49
    xml = ET.tostring(wf.export_to_xml())
50
    wf2 = Workflow.import_from_xml_tree(ET.fromstring(xml))
51
    assert ET.tostring(export_to_indented_xml(wf)) == ET.tostring(export_to_indented_xml(wf2))
52
    return wf2
53

  
45 54
def test_empty(pub):
46 55
    wf = Workflow(name='empty')
47 56
    assert_import_export_works(wf)
......
567 576
    st1 = wf.add_status('Status1', 'st1')
568 577

  
569 578
    sendsms = SendSMSWorkflowStatusItem()
570
    sendsms.to = ['0123456789']
579
    sendsms.to = ['0123456789', '']
571 580
    sendsms.body = 'hello'
572 581
    st1.items.append(sendsms)
573 582
    sendsms.parent = st1
574 583

  
575 584
    Role.wipe()
576
    wf2 = assert_import_export_works(wf)
585
    wf2 = assert_xml_import_export_works(wf)
577 586
    assert Role.count() == 0
578 587
    assert wf2.possible_status[0].items[0].to == sendsms.to
579 588

  
wcs/workflows.py
832 832
                continue
833 833
            if list(el):
834 834
                if type(getattr(self, attribute)) is list:
835
                    v = [x.text.encode(charset) for x in el]
835
                    v = [x.text.encode(charset) if x.text is not None else ''
836
                         for x in el]
836 837
                elif type(getattr(self, attribute)) is dict:
837 838
                    v = {}
838 839
                    for e in el:
839
-