Projet

Général

Profil

0001-workflows-don-t-try-substituting-images-with-non-ima.patch

Frédéric Péters, 24 juin 2017 12:24

Télécharger (1,97 ko)

Voir les différences:

Subject: [PATCH] workflows: don't try substituting images with non-images
 (#17174)

 tests/test_workflows.py   | 15 +++++++++++++++
 wcs/wf/export_to_model.py |  2 ++
 2 files changed, 17 insertions(+)
tests/test_workflows.py
1931 1931
    # check the image has been replaced by the one from the formdata
1932 1932
    assert zinfo.file_size == len(image_data)
1933 1933

  
1934
    # check with missing data or wrong kind of data
1935
    for field_value in (None, 'wrong kind'):
1936
        formdata = formdef.data_class()()
1937
        formdata.data = {'3': field_value}
1938
        formdata.just_created()
1939
        formdata.store()
1940
        pub.substitutions.feed(formdata)
1941

  
1942
        item.perform(formdata)
1943

  
1944
        zfile = zipfile.ZipFile(formdata.evolution[-1].parts[0].filename, mode='r')
1945
        zinfo = zfile.getinfo('Pictures/10000000000000320000003276E9D46581B55C88.jpg')
1946
        # check the original image has been left
1947
        assert zinfo.file_size == 580
1948

  
1934 1949
def test_global_timeouts(pub):
1935 1950
    FormDef.wipe()
1936 1951
    Workflow.wipe()
wcs/wf/export_to_model.py
436 436
                        variable_image = self.compute(name)
437 437
                    except:
438 438
                        continue
439
                    if not hasattr(variable_image, 'get_content'):
440
                        continue
439 441
                    image = [x for x in node.getchildren() if x.tag == DRAW_IMAGE][0]
440 442
                    new_images[image.attrib.get(XLINK_HREF)] = variable_image
441 443

  
442
-