mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
* standardise plot data output * add data required for new anchors to renderer properties * feed dvc-render updates into API output * update --json --split api with new data types (send split anchor definitions as strings) * accomodate zoom and pan anchor * switch anchor_revs to revs_with_datapoints * accomodate height and width anchors * drop terrible idea of holding all data as strings * fix plot having multiple x fields * move inferred properties off vega converter class
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from dvc.render import FILENAME, REVISION, SRC
|
|
from dvc.render.converter.image import ImageConverter
|
|
|
|
|
|
def test_image_converter_no_out():
|
|
data = {"image.png": b"content"}
|
|
converter = ImageConverter("image.png", data)
|
|
datapoints, _ = converter.flat_datapoints("r")
|
|
|
|
assert datapoints[0] == {
|
|
REVISION: "r",
|
|
FILENAME: "image.png",
|
|
SRC: converter._encode_image(b"content"),
|
|
}
|
|
|
|
|
|
def test_image_converter_with_out(tmp_dir):
|
|
data = {"image.png": b"content"}
|
|
converter = ImageConverter("image.png", data, {"out": tmp_dir / "foo"})
|
|
|
|
datapoints, _ = converter.flat_datapoints("r")
|
|
|
|
assert datapoints[0] == {
|
|
REVISION: "r",
|
|
FILENAME: "image.png",
|
|
SRC: str(tmp_dir / "foo" / "r_image.png"),
|
|
}
|
|
|
|
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 = {"image.png": b"content"}
|
|
converter = ImageConverter("image.png", data, {"out": tmp_dir / "foo"})
|
|
|
|
datapoints, _ = converter.flat_datapoints("feature/r")
|
|
|
|
assert datapoints[0] == {
|
|
REVISION: "feature/r",
|
|
FILENAME: "image.png",
|
|
SRC: str(tmp_dir / "foo" / "feature_r_image.png"),
|
|
}
|
|
|
|
assert (tmp_dir / "foo" / "feature_r_image.png").read_bytes() == b"content"
|