Skip to content

Commit 16d4f24

Browse files
committed
chore(test): added test for re-canvasing modules
1 parent a6a0357 commit 16d4f24

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

src/clickgen/parser/png.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ def _parse(self) -> List[CursorFrame]:
7474
raise ValueError(
7575
f"'sizes' input '{s}' must be an integer or integers separated by ':'."
7676
)
77-
except IndexError:
78-
raise ValueError(
79-
f"'sizes' input '{s}' must contain one ':' to separate sizes."
80-
)
8177
elif isinstance(s, int):
8278
size = s
8379
canvas_size = s

src/clickgen/writer/windows.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ def re_canvas(size: int, img: Image.Image):
5757
re_canvas(96, clone).save(blob, "PNG")
5858
elif width <= 128 or height <= 128:
5959
re_canvas(128, clone).save(blob, "PNG")
60-
elif width <= 256 or height <= 256:
61-
re_canvas(256, clone).save(blob, "PNG")
6260
else:
63-
raise ValueError(f"Unable to re-canvas windows cursors: {width}x{height}")
61+
re_canvas(256, clone).save(blob, "PNG")
6462

6563
blob.seek(0)
6664
image_data.append(blob.read())

tests/parser/test_png_parser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ def test_single_png_parser_raises_01(blob):
4545
SinglePNGParser(blob, hotspot=(201, 100))
4646

4747

48+
def test_single_png_parser_raises_size_error_for_canvasing(blob):
49+
with pytest.raises(ValueError):
50+
SinglePNGParser(blob, hotspot=(3, 3), sizes=["test"])
51+
with pytest.raises(ValueError):
52+
SinglePNGParser(blob, hotspot=(3, 3), sizes=["20:"])
53+
with pytest.raises(ValueError):
54+
SinglePNGParser(blob, hotspot=(3, 3), sizes=[":20"])
55+
56+
with pytest.raises(TypeError):
57+
SinglePNGParser(blob, hotspot=(3, 3), sizes=[(20, 20)])
58+
59+
4860
def test_multi_png_parser(blobs, hotspot, sizes, delay):
4961
p = MultiPNGParser(blobs, hotspot, sizes, delay)
5062

tests/writer/test_windows_writer.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ def test_windows_cur_writer(cursor_frame, x11_tmp_dir: Path):
1818
assert cfile.is_file()
1919

2020

21+
def test_windows_cur_writer_re_canvas(image: Image, hotspot, delay):
22+
def cur_frame(size: int):
23+
i = image.resize(size=(size, size), resample=3)
24+
return CursorImage(i, hotspot, nominal=31)
25+
26+
to_cur(
27+
CursorFrame(
28+
[
29+
cur_frame(20),
30+
cur_frame(40),
31+
cur_frame(60),
32+
cur_frame(90),
33+
cur_frame(120),
34+
cur_frame(250),
35+
],
36+
delay,
37+
)
38+
)
39+
40+
2141
def test_windows_cur_writer_raises(image: Image, hotspot, delay):
2242
i = image.resize(size=(500, 500), resample=3)
2343
c = CursorImage(i, hotspot, nominal=i.size[0])

0 commit comments

Comments
 (0)