37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
#!/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", "fetch-play-charts.py")
|
|
FIXTURE = os.path.join(HERE, "fixtures", "appbrain-popular.html")
|
|
|
|
def run():
|
|
out = subprocess.check_output(
|
|
[sys.executable, SCRIPT, "popular", "--region", "us", "--html-file", FIXTURE])
|
|
return json.loads(out)
|
|
|
|
def main():
|
|
d = run()
|
|
fails = []
|
|
def check(name, cond):
|
|
print(f"{'PASS' if cond else 'FAIL'}: {name}")
|
|
if not cond: fails.append(name)
|
|
|
|
check("source", d["source"] == "appbrain")
|
|
check("chart", d["chart"] == "popular")
|
|
check("count", d["count"] == 2)
|
|
e0 = d["entries"][0]
|
|
check("rank 1", e0["rank"] == 1)
|
|
check("name", e0["name"] == "Habit Tracker")
|
|
check("package", e0["package"] == "com.example.habit")
|
|
check("developer", e0["developer"] == "Focus Labs")
|
|
check("category", e0["category"] == "Productivity")
|
|
check("rating", e0["rating"] == 4.6)
|
|
check("installs", e0["installs"] == "5,000,000+")
|
|
for k in ["rank", "name", "package", "developer", "category", "rating", "installs"]:
|
|
check(f"key present: {k}", k in e0)
|
|
check("second package", d["entries"][1]["package"] == "com.example.budget")
|
|
sys.exit(1 if fails else 0)
|
|
|
|
main()
|