File size: 2,477 Bytes
5e5f55c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""Compare regenerate.py output against the published 2026-11-21 Pulse files."""

from __future__ import annotations

import csv
import json
import subprocess
import sys
import tempfile
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / "scripts" / "regenerate.py"
RAW = ROOT / "data" / "data_raw.json"
PUB_JSON = ROOT / "data" / "x402-pulse-2026-11.json"
PUB_CSV = ROOT / "data" / "x402-pulse-2026-11.csv"


def main() -> int:
    published = json.loads(PUB_JSON.read_text())
    with tempfile.TemporaryDirectory() as td:
        out = Path(td)
        subprocess.check_call(
            [
                sys.executable,
                str(SCRIPT),
                "--source",
                str(RAW),
                "--out",
                str(out),
                "--slug",
                "x402-pulse-2026-11",
                "--published",
                "2026-11-21",
            ]
        )
        got = json.loads((out / "data" / "x402-pulse-2026-11.json").read_text())

        assert got["totals"] == published["totals"], (got["totals"], published["totals"])
        assert got["excluded_scriptmasterlabs_rows"] == published["excluded_scriptmasterlabs_rows"]
        assert got["week_over_week"]["nov_7_13"] == published["week_over_week"]["nov_7_13"]
        assert got["week_over_week"]["nov_14_20"] == published["week_over_week"]["nov_14_20"]
        assert got["week_over_week"]["multiple"] == published["week_over_week"]["multiple"]
        assert got["price_mix"] == published["price_mix"]
        assert got["concentration_since_2026_11_14"] == published["concentration_since_2026_11_14"]
        assert got["largest_seller_since_2026_11_14"] == published["largest_seller_since_2026_11_14"]
        assert got["supply_snapshot"] == published["supply_snapshot"]
        assert got["quotable"] == published["quotable"]
        assert got["window"] == published["window"]
        assert got["daily"] == published["daily"]
        assert got["caveats"] == published["caveats"]

        with (out / "data" / "x402-pulse-2026-11.csv").open() as f, PUB_CSV.open() as g:
            got_rows = list(csv.reader(f))
            pub_rows = list(csv.reader(g))
        assert got_rows == pub_rows, "CSV does not match the published file"

    print("regenerate.py matches the published 2026-11 Pulse CSV, totals, quotable, seller and caveats")
    return 0


if __name__ == "__main__":
    sys.exit(main())