43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import sys
|
|
|
|
|
|
TOOLS = Path(__file__).resolve().parents[1]
|
|
if str(TOOLS) not in sys.path:
|
|
sys.path.insert(0, str(TOOLS))
|
|
|
|
import _common
|
|
from new_project import release_files
|
|
|
|
|
|
class ChannelLayoutTest(unittest.TestCase):
|
|
def test_tree_root_is_already_channel_scoped(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
_common.set_tree_root(root, channel="a" * 32)
|
|
self.assertEqual(_common.CAMPAIGN_DIR, root.resolve() / "web")
|
|
self.assertEqual(_common.SYNC_DIR, root.resolve() / "sync")
|
|
|
|
def test_release_manifest_files_are_relative_and_hashed(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
(root / "web").mkdir()
|
|
(root / "sync").mkdir()
|
|
(root / "web" / "support.html").write_bytes(b"support")
|
|
(root / "sync" / "daily.html").write_bytes(b"daily")
|
|
|
|
files = release_files(root)
|
|
|
|
self.assertEqual(
|
|
[item["path"] for item in files],
|
|
["web/support.html", "sync/daily.html"],
|
|
)
|
|
self.assertTrue(all(len(str(item["sha256"])) == 64 for item in files))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|