38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import os
|
|
import runpy
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
|
|
class PhotoManifestTest(unittest.TestCase):
|
|
def test_photo_receipts_accept_single_and_double_quoted_ids(self):
|
|
first = "a" * 64
|
|
second = "b" * 64
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
(root / "_site/art").mkdir(parents=True)
|
|
(root / "_site/snippets").mkdir(parents=True)
|
|
(root / "_site/art/index.html").write_text(
|
|
f'<span id="photo-{first}"></span><span id=\'photo-{second}\'></span>'
|
|
)
|
|
(root / "_site/snippets/index.html").write_text("")
|
|
|
|
with patch("os.environ", {"GITHUB_SHA": "test-commit"}):
|
|
old_cwd = Path.cwd()
|
|
try:
|
|
os.chdir(root)
|
|
script = Path(__file__).resolve().parents[1] / "photo-manifest.py"
|
|
runpy.run_path(str(script))
|
|
finally:
|
|
os.chdir(old_cwd)
|
|
|
|
manifest = (root / "_site/photo-publication.json").read_text()
|
|
self.assertIn(first, manifest)
|
|
self.assertIn(second, manifest)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|