Skip to content

Commit

Permalink
Added tests for truncate_titles() (#232)
Browse files Browse the repository at this point in the history
* Added tests for truncate_titles()

* Fixed formatting issues
  • Loading branch information
aenlemmea authored Oct 23, 2023
1 parent cd8f98b commit 9531fbc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_viz_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from PIL import Image

from cleanvision.utils.viz_manager import VizManager
from cleanvision.utils.viz_manager import VizManager, truncate_titles


class TestVizManager:
Expand Down Expand Up @@ -30,3 +30,25 @@ def test_individual_images(self, images, title_info):
)
def test_image_sets(self, image_sets, title_info_sets):
VizManager.image_sets(image_sets, title_info_sets, 4, (2, 2))


def test_truncate_titles():
assert truncate_titles(
2,
[
"/home/usr/proj/dev/product/dataset/images/image_0001.img",
"/home/usr/proj/dev/product/dataset/images/image_0002.img",
],
) == ["...es/image_0001.img", "...es/image_0002.img"]

assert truncate_titles(2, ["image.jpeg", "image2.jpeg"]) == [
"image.jpeg",
"image2.jpeg",
]
assert truncate_titles(
2,
[
"/pictures/mount/image_0001.img",
"/home/usr/proj/dev/product/dataset/images/image_0002.img",
],
) == ["/pictures/mount/i...", "/home/usr/proj/de..."]

0 comments on commit 9531fbc

Please sign in to comment.