chore(wallpaper_changer): move python file to subdir

This commit is contained in:
Lucas Vivo committed 2026-11-20 15:58:05 +01:00
1 parent f2d5311719
commit 6ac508745c
66 files changed
+127 -46

No files matched your search

@@ -0,0 +1,62 @@
import unittest
from pathlib import Path
from unittest.mock import patch
from wallpaper_changer.argument_parser import parse_args
from wallpaper_changer.config import Config
from wallpaper_changer.monitor_manager import Monitor, ScreenLayout
from wallpaper_changer.wallpaper_changer import WallpaperChanger
class WallpaperChangerTests(unittest.TestCase):
def parse_args(self, *arguments: str):
return parse_args(list(arguments))
def setUp(self) -> None:
args = self.parse_args("--disable-encryption", "--decode-and-leave", "--minutes", "1")
self.cfg = Config.load(args)
self.layout = ScreenLayout((Monitor(1920, 1080, 0, set()),))
def test_change_wallpaper_scans_builds_and_sets_wallpaper(self) -> None:
images = ["image-1"]
wallpaper_path = Path("/wallpapers/wallpaper.jpg")
search_terms_gen = ["mountain"]
search_terms_monitor = ["lake"]
exclude = ["night"]
with (
patch("wallpaper_changer.wallpaper_changer.ImageRepository") as repository,
patch("wallpaper_changer.wallpaper_changer.WallpaperBuilder") as builder,
patch("wallpaper_changer.wallpaper_changer.WallpaperSetter") as setter,
):
repository.return_value.scan.return_value = images
builder.return_value.build.return_value = (wallpaper_path, [])
WallpaperChanger().change_wallpaper(
self.cfg,
self.layout,
search_terms_gen,
search_terms_monitor,
exclude,
)
repository.assert_called_once_with(self.cfg.img_dir)
repository.return_value.scan.assert_called_once_with(
self.cfg.private_key,
disable_encryption=True,
)
builder.return_value.build.assert_called_once_with(
images,
self.layout,
private_key=self.cfg.private_key,
wallpaper_dir=self.cfg.wallpaper_dir,
search_terms_monitor=search_terms_monitor,
search_terms_gen=search_terms_gen,
exclude=exclude,
decode_and_leave=True,
disable_encryption=True,
)
setter.return_value.set_ubuntu.assert_called_once_with(wallpaper_path)
if __name__ == "__main__":
unittest.main()