-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.py
More file actions
55 lines (43 loc) · 1.77 KB
/
Copy pathverify.py
File metadata and controls
55 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Smoke test for 07-migrate. See SUITE.md "07 -- migrate" for the required
markers this checks.
"""
import os
import sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
import bootstrap # noqa: E402
import inky # noqa: E402
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
dist = bootstrap.inky_example("07-migrate")
migrated_path = os.path.join(dist, "migrated.inky")
built_path = os.path.join(dist, "email.html")
if not os.path.isfile(migrated_path) or not os.path.isfile(built_path):
print("07-migrate: missing dist output -- run examples/07-migrate/run.py first", file=sys.stderr)
sys.exit(1)
with open(migrated_path, encoding="utf-8") as f:
migrated = f.read()
with open(built_path, encoding="utf-8") as f:
built = f.read()
failures = 0
if 'lg="' not in migrated:
print('07-migrate: expected lg=" in migrated output (large -> lg did not happen)', file=sys.stderr)
failures += 1
if 'large="' in migrated:
print('07-migrate: found leftover large=" in migrated output', file=sys.stderr)
failures += 1
# Re-run migrate_with_details directly to check the reported change count
# (run.py only writes files; re-deriving here keeps this check honest
# without parsing run.py's stdout).
with open(os.path.join(THIS_DIR, "legacy-v1.inky"), encoding="utf-8") as f:
legacy = f.read()
result = inky.migrate_with_details(legacy)
change_count = len(result["changes"])
if change_count < 5:
print(f"07-migrate: expected at least 5 changes, got {change_count}", file=sys.stderr)
failures += 1
if "<table" not in built:
print("07-migrate: expected <table in built output (migrated template did not build to table markup)", file=sys.stderr)
failures += 1
if failures > 0:
sys.exit(1)
print("07-migrate: ok")