#!/usr/bin/env python3 import json, subprocess, sys, os HERE = os.path.dirname(os.path.abspath(__file__)) SCRIPT = os.path.join(HERE, "..", "skills", "market-research", "scripts", "play.py") SEARCH = os.path.join(HERE, "fixtures", "play-search.html") DETAILS = os.path.join(HERE, "fixtures", "play-details.html") def run(*args): return json.loads(subprocess.check_output([sys.executable, SCRIPT, *args])) def main(): fails = [] def check(name, cond): print(f"{'PASS' if cond else 'FAIL'}: {name}") if not cond: fails.append(name) r = run("resolve", "Habit Tracker", "--search-file", SEARCH, "--details-file", DETAILS) check("package", r["package"] == "com.example.habit") check("play_url", r["play_url"] == "https://play.google.com/store/apps/details?id=com.example.habit") check("name", r["name"] == "Habit Tracker") check("rating", r["rating"] == 4.6) check("installs", r["installs"] == "1B+") check("last_updated", r["last_updated"] == "Jun 1, 2026") check("developer", r["developer"] == "Focus Labs") c = run("count", "habit tracker", "--search-file", SEARCH) check("app_count", c["app_count"] == 3) check("avg_rating", c["avg_rating"] == 4.2) # mean(4.6,4.1,3.9)=4.2 check("top_packages has habit", "com.example.habit" in c["top_packages"]) check("top_packages distinct", len(c["top_packages"]) == len(set(c["top_packages"]))) sys.exit(1 if fails else 0) main()