fix: 校验独立站公开快照并补充自托管说明
This commit is contained in:
@@ -10,9 +10,9 @@ test("独立首页只展示家纺情报并加载独立入口", async () => {
|
||||
const dongguanCss = await text("public/assets/fonts/dongguan-bold/result.css");
|
||||
assert.match(html, /三笙AI情报局/);
|
||||
assert.match(html, /assets\/js\/app\.js/);
|
||||
assert.match(html, /assets\/js\/app\.js\?v=20260815a/);
|
||||
assert.match(html, /assets\/js\/app\.js\?v=20260817a/);
|
||||
assert.match(html, /assets\/css\/base\.css\?v=20260814h/);
|
||||
assert.match(html, /assets\/css\/intelligence\.css\?v=20260815a/);
|
||||
assert.match(html, /assets\/css\/intelligence\.css\?v=20260817a/);
|
||||
assert.match(html, /<details[^>]+class="intelligence-metrics"/);
|
||||
assert.match(html, /<summary[^>]+class="intelligence-utility-row"/);
|
||||
assert.doesNotMatch(html, /id="intelligenceShareBtn"/);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from scripts.verify_public_snapshot import check_url
|
||||
|
||||
|
||||
class VerifyPublicSnapshotTests(unittest.TestCase):
|
||||
def test_public_snapshot_must_match_generated_at_and_as_of_date(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "textile-intelligence.json"
|
||||
path.write_text(json.dumps({"generated_at": "2026-08-17T12:30:21Z", "as_of_date": "2026-08-17"}), encoding="utf-8")
|
||||
|
||||
class Response:
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
return False
|
||||
|
||||
def read(self):
|
||||
return b'{"generated_at":"2026-08-17T12:30:21Z","as_of_date":"2026-08-17"}'
|
||||
|
||||
with patch("scripts.verify_public_snapshot.urlopen", return_value=Response()):
|
||||
self.assertEqual(check_url("https://example.test", "/data/textile-intelligence.json", path), ("2026-08-17T12:30:21Z", "2026-08-17"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user