@@ -157,13 +157,16 @@ def setUp(self):
157157 )
158158 (self .root / "config" ).mkdir ()
159159 (self .root / "assets" ).mkdir ()
160- self .default = self .root / "assets/ds .jpg"
161- self .default .write_bytes (b"default " )
160+ self .image = self .root / "assets/custom .jpg"
161+ self .image .write_bytes (b"custom " )
162162
163163 def test_priority_and_missing_custom_do_not_fall_back_to_another_image (self ):
164- self .assertEqual (
165- wallpaper .wallpaper_view ("script" )["source" ], str (self .default )
166- )
164+ legacy = self .root / "assets/ds.jpg"
165+ legacy .write_bytes (b"old bundled background" )
166+ state = wallpaper .wallpaper_view ("script" )
167+ self .assertEqual (state ["mode" ], "gradient" )
168+ self .assertEqual (state ["source" ], "" )
169+ self .assertIsNone (state ["token" ])
167170 native = self .root / "native.png"
168171 native .write_bytes (b"native" )
169172 self .relative .return_value = "native.png"
@@ -179,27 +182,28 @@ def test_priority_and_missing_custom_do_not_fall_back_to_another_image(self):
179182
180183 def test_save_reset_preserve_other_script_and_source_files (self ):
181184 save_wallpapers ({"other" : "unchanged.png" })
182- wallpaper .set_wallpaper ("script" , str (self .default ))
185+ wallpaper .set_wallpaper ("script" , str (self .image ))
183186 self .assertEqual (
184- load_wallpapers (), {"other" : "unchanged.png" , "script" : str (self .default )}
187+ load_wallpapers (), {"other" : "unchanged.png" , "script" : str (self .image )}
185188 )
186189 wallpaper .set_wallpaper ("script" , None )
187190 self .assertEqual (load_wallpapers (), {"other" : "unchanged.png" })
188- self .assertEqual (self .default .read_bytes (), b"default " )
191+ self .assertEqual (self .image .read_bytes (), b"custom " )
189192 before = (self .root / "config/wallpaper.json" ).read_bytes ()
190193 for path in ("" , "missing.png" , str (self .root ), "bad.exe" ):
191194 with self .subTest (path = path ), self .assertRaises (wallpaper .InvalidWallpaper ):
192195 wallpaper .set_wallpaper ("script" , path )
193196 self .assertEqual ((self .root / "config/wallpaper.json" ).read_bytes (), before )
194197
195198 def test_cache_uses_current_source_identity_and_rejects_stale_data (self ):
199+ wallpaper .set_wallpaper ("script" , str (self .image ))
196200 state = wallpaper .wallpaper_view ("script" )
197201 jpeg = base64 .b64encode (b"\xff \xd8 test\xff \xd9 " ).decode ()
198202 self .assertTrue (wallpaper .save_wallpaper_cache ("script" , state ["token" ], jpeg ))
199203 cache = Path (wallpaper .wallpaper_view ("script" )["cache" ])
200204 self .assertEqual (cache .parent , self .root / "config/wallpaper_cache" )
201205 self .assertEqual (cache .read_bytes (), b"\xff \xd8 test\xff \xd9 " )
202- self .default .write_bytes (b"changed source" )
206+ self .image .write_bytes (b"changed source" )
203207 self .assertIsNone (wallpaper .wallpaper_view ("script" )["cache" ])
204208 self .assertFalse (wallpaper .save_wallpaper_cache ("script" , state ["token" ], jpeg ))
205209 for invalid in ("not base64" , base64 .b64encode (b"not jpeg" ).decode ()):
0 commit comments