render: image_converter: Support slash in revision.

Fixes #7934
This commit is contained in:
David de la Iglesia Castro
2022-06-27 10:53:03 +02:00
committed by Paweł Redzyński
parent d448eb5fc1
commit c336507e51
2 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -20,7 +20,8 @@ class ImageConverter:
image_data: bytes,
) -> "StrPath":
img_path = os.path.join(
path, f"{revision}_{filename.replace(os.sep, '_')}"
path,
f"{revision}_{filename}".replace(os.sep, "_").replace("/", "_"),
)
with open(img_path, "wb") as fd:
fd.write(image_data)
+16
View File
@@ -28,3 +28,19 @@ def test_image_converter_with_out(tmp_dir):
}
assert (tmp_dir / "foo" / "r_image.png").read_bytes() == b"content"
def test_image_converter_with_slash_in_revision(tmp_dir):
"""Regression test for #7934"""
data = b"content"
converter = ImageConverter({"out": tmp_dir / "foo"})
datapoints, _ = converter.convert(data, "feature/r", "image.png")
assert datapoints[0] == {
REVISION_FIELD: "feature/r",
"filename": "image.png",
SRC_FIELD: str(tmp_dir / "foo" / "feature_r_image.png"),
}
assert (tmp_dir / "foo" / "feature_r_image.png").read_bytes() == b"content"