Skip to content

Commit

Permalink
feat: Show detailed error for missing bitmaps in ctgen cursors conf…
Browse files Browse the repository at this point in the history
…ig parsing
  • Loading branch information
ful1e5 committed Jun 5, 2024
1 parent a979a21 commit 2fece17
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### What's New?

- Show detailed error for missing bitmaps in `ctgen` cursors config parsing

## [v2.2.3] - 25 May 2024

### What's New?
Expand Down
5 changes: 5 additions & 0 deletions src/clickgen/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ def size_typing(s: Union[int, List[int]]) -> List[int]:

blobs = [f.read_bytes() for f in sorted(config.bitmaps_dir.glob(v["png"]))]

if not blobs:
raise FileNotFoundError(
f"Bitmaps not found '{v["png"]}' in '{config.bitmaps_dir}'"
)

x11_cursor = None
x11_cursor_name = None
if "x11_name" in v:
Expand Down
21 changes: 19 additions & 2 deletions tests/test_configparser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from pathlib import Path

import pytest

from clickgen.configparser import (
ClickgenConfig,
parse_config_file,
parse_config_section,
parse_cursors_section,
parse_json_file,
parse_theme_section,
parse_toml_file,
Expand Down Expand Up @@ -75,10 +78,10 @@ def test_x11_sizes_deprecation_message(capsys):
def test_parse_config_section():
c = parse_config_section(Path(), dd2)
assert isinstance(c.bitmaps_dir, Path)
assert c.bitmaps_dir.name is "test"
assert c.bitmaps_dir.name == "test"
assert c.bitmaps_dir.is_absolute()
assert isinstance(c.out_dir, Path)
assert c.out_dir.name is "test"
assert c.out_dir.name == "test"
assert c.out_dir.is_absolute()

assert c.platforms == "test"
Expand Down Expand Up @@ -178,3 +181,17 @@ def test_parse_config_files(samples_dir: Path):
fp = samples_dir / f"sample.{ext}"
c: ClickgenConfig = parse_config_file(fp)
assert_clickgen_config(c)


def test_parse_cursor_section_handles_png_not_found_exception():
exp_dd1 = dd1
exp_dd1["cursors"] = {
"fallback_settings": {},
"bitmap1": {"png": "test.png", "x11_name": "test", "win_name": "test"},
}

c = parse_config_section(Path(), dd2)

with pytest.raises(FileNotFoundError) as e:
parse_cursors_section(exp_dd1, c)
print(e)

0 comments on commit 2fece17

Please sign in to comment.