okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
c9b9960
main
1"""The bundle staged on a remote host holds the python sources and nothing a 2tool left in the tree: a cache directory would travel to every host, and 3shipping it changed what the host runs from.""" 4 5import io 6from pathlib import Path 7import sys 8import tarfile 9import tempfile 10import unittest 11from unittest import mock 12 13sys .path .insert (0 ,str (Path (__file__ ).resolve ().parents [2 ]/ "priv" / "python" )) 14import albedo_bundle # noqa: E402 15import albedo_ssh # noqa: E402 16 17 18class ArchiveTest (unittest .TestCase ): 19def test_sources_travel_and_caches_do_not (self ): 20with tempfile .TemporaryDirectory ()as scratch : 21root = Path (scratch ) 22for name in ( 23"a.py" , 24"plugins/b.py" , 25"plugins/__pycache__/b.cpython-314.pyc" , 26".ruff_cache/0.16.10/entry" , 27"plugins/.mypy_cache/meta.json" , 28 ): 29path = root / name 30path .parent .mkdir (parents = True ,exist_ok = True ) 31path .write_text ("x" ) 32with mock .patch .object (albedo_bundle ,"ROOT" ,root ): 33data = albedo_ssh .archive () 34names = { 35name .removeprefix ("./" ) 36for name in tarfile .open (fileobj = io .BytesIO (data )).getnames () 37 } 38self .assertEqual ( 39 {name for name in names if not name .endswith (("plugins" ,"." ))}, 40 {"a.py" ,"plugins/b.py" }, 41 ) 42 43 44if __name__ == "__main__" : 45unittest .main ()