Esempio n. 1
0
def test_custom_valid_ext(name, suffix, expected):
    alt_suffix = suffix.replace(".", "")
    result1 = validate_image_name(name, suffix=suffix)
    result2 = validate_image_name(name, suffix=alt_suffix)

    assert result1 == expected
    assert result2 == expected
Esempio n. 2
0
def test_custom_valid_ext():
    for dext in SUPPORTED_FORMATS:
        ext = dext.replace(".", "")
        result1 = validate_image_name(filename_no_ext, suffix=ext)
        result2 = validate_image_name(filename_no_ext, suffix=dext)
        expected = f"{filename_no_ext}.{ext}"

        assert result1 == expected
        assert result2 == expected
Esempio n. 3
0
def test_default():
    result = validate_image_name(filename_no_ext)
    expected = f"{filename_no_ext}.png"
    assert result == expected

    result = validate_image_name(filename_png)
    assert result == expected

    result = validate_image_name(filename_pdf)
    expected = str(filename_pdf)
    assert result == expected
Esempio n. 4
0
    def _setup_save(self, fname, render) -> str:

        self._render_on_demand(render)

        rensources = self._get_render_sources()
        if fname is None:
            # if a volume source present, use its affiliated ds for fname
            if len(rensources) > 0:
                rs = rensources[0]
                basename = rs.data_source.ds.basename
                if isinstance(rs.field, str):
                    field = rs.field
                else:
                    field = rs.field[-1]
                fname = f"{basename}_Render_{field}"
            # if no volume source present, use a default filename
            else:
                fname = "Render_opaque"

        fname = validate_image_name(fname)
        mylog.info("Saving rendered image to %s", fname)
        return fname
Esempio n. 5
0
def test_default(name, expected):
    result = validate_image_name(name)
    assert result == expected