mirror of
https://github.com/seanbetts/steam-hardware-watch.git
synced 2026-10-06 02:00:19 +02:00
Capture Steam Machine launch watch baseline
This commit is contained in:
1 parent
dab6f8b6d0
commit
ed9f4500a2
23 files changed
+1926
-82
No files matched your search
@@ -159,6 +159,7 @@ class CheckKomodoTests(unittest.TestCase):
|
||||
"PATH": f"{fake_bin}:{env['PATH']}",
|
||||
"KOMODO_ENV_FILE": str(tmp_path / "missing-komodo-env.sh"),
|
||||
"KOMODO_PLAYWRIGHT_FALLBACK": "1",
|
||||
"KOMODO_AUTO_BOOTSTRAP": "0",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -188,6 +189,106 @@ class CheckKomodoTests(unittest.TestCase):
|
||||
(run_dir / "reports" / "komodo-frame-sections.tsv").read_text(encoding="utf-8"),
|
||||
)
|
||||
|
||||
def test_playwright_fallback_bootstraps_dedicated_browser_when_cdp_is_stale(self):
|
||||
tmp = TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
tmp_path = Path(tmp.name)
|
||||
run_dir = tmp_path / "run"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
env_file = tmp_path / "komodo-env.sh"
|
||||
bootstrap_log = tmp_path / "bootstrap.log"
|
||||
|
||||
env_file.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"export KOMODO_PLAYWRIGHT_FALLBACK=1",
|
||||
f'export PLAYWRIGHT_PROFILE_DIR="{tmp_path / "profile"}"',
|
||||
'export PLAYWRIGHT_CDP_ENDPOINT="http://127.0.0.1:9"',
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
write_executable(
|
||||
fake_bin / "curl",
|
||||
r"""
|
||||
#!/bin/sh
|
||||
for arg do
|
||||
url="$arg"
|
||||
done
|
||||
case "$url" in
|
||||
http://127.0.0.1:9/json/version)
|
||||
exit 7
|
||||
;;
|
||||
*wp-json/wp/v2/product/413763*)
|
||||
printf '%s\n' '{"modified":"2026-05-14T12:00:00","title":{"rendered":"Steam Controller"}}'
|
||||
;;
|
||||
*wp-json/wp/v2/sections?search=Steam%20Controller*|*wp-json/wp/v2/media?search=Steam%20Controller*|*wp-json/wp/v2/media?parent=*)
|
||||
printf '%s\n' '[]'
|
||||
;;
|
||||
*wp-json/wp/v2/product/413772*|*wp-json/wp/v2/product/413776*|*wp-json/wp/v2/sections?search=Steam%20Machine*|*wp-json/wp/v2/sections?search=Steam%20Frame*)
|
||||
exit 22
|
||||
;;
|
||||
*wp-json/*)
|
||||
printf '%s\n' '{"name":"Komodo"}'
|
||||
;;
|
||||
*)
|
||||
exit 22
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
write_executable(fake_bin / "playwright-cli", "#!/bin/sh\nexit 0")
|
||||
write_executable(
|
||||
fake_bin / "node",
|
||||
r"""
|
||||
#!/bin/sh
|
||||
url="$2"
|
||||
output="$3"
|
||||
case "$url" in
|
||||
*wp-json/wp/v2/product/413772*)
|
||||
printf '%s\n' '{"modified":"2026-05-14T12:00:00","title":{"rendered":"Steam Machine"}}' > "$output"
|
||||
;;
|
||||
*wp-json/wp/v2/product/413776*)
|
||||
printf '%s\n' '{"modified":"2026-05-14T12:00:00","title":{"rendered":"Steam Frame"}}' > "$output"
|
||||
;;
|
||||
*)
|
||||
printf '%s\n' '[]' > "$output"
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
tmp_path / "bootstrap-komodo.sh",
|
||||
f"#!/bin/sh\nprintf '%s\\n' bootstrap >> '{bootstrap_log}'\ncat > '{env_file}' <<'EOF'\nexport KOMODO_PLAYWRIGHT_FALLBACK=1\nexport PLAYWRIGHT_PROFILE_DIR=\"{tmp_path / 'profile'}\"\nexport PLAYWRIGHT_CDP_ENDPOINT=\"http://127.0.0.1:55684\"\nEOF\n",
|
||||
)
|
||||
|
||||
env = os.environ.copy()
|
||||
env.update(
|
||||
{
|
||||
"PATH": f"{fake_bin}:{env['PATH']}",
|
||||
"KOMODO_ENV_FILE": str(env_file),
|
||||
"KOMODO_BOOTSTRAP_CMD": str(tmp_path / "bootstrap-komodo.sh"),
|
||||
}
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
[str(ROOT / "scripts" / "check_komodo.sh"), str(run_dir)],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
self.assertTrue(bootstrap_log.exists())
|
||||
self.assertIn("bootstrap", bootstrap_log.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -83,6 +83,7 @@ class CheckSteamDBTests(unittest.TestCase):
|
||||
"FAKE_NODE_MODE": node_mode,
|
||||
"FAKE_LOG_DIR": str(log_dir),
|
||||
"STEAMDB_PLAYWRIGHT_FALLBACK": "1",
|
||||
"STEAMDB_AUTO_BOOTSTRAP": "0",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -130,6 +131,86 @@ class CheckSteamDBTests(unittest.TestCase):
|
||||
errors = (run_dir / "reports" / "steamdb-errors.txt").read_text(encoding="utf-8")
|
||||
self.assertEqual("", errors)
|
||||
|
||||
def test_playwright_fallback_bootstraps_dedicated_browser_when_cdp_is_stale(self):
|
||||
tmp = TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
tmp_path = Path(tmp.name)
|
||||
run_dir = tmp_path / "run"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
log_dir = tmp_path / "logs"
|
||||
log_dir.mkdir()
|
||||
env_file = tmp_path / "steamdb-env.sh"
|
||||
bootstrap_log = tmp_path / "bootstrap.log"
|
||||
|
||||
env_file.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"export STEAMDB_PLAYWRIGHT_FALLBACK=1",
|
||||
f'export STEAMDB_PROFILE_DIR="{tmp_path / "profile"}"',
|
||||
'export STEAMDB_CDP_ENDPOINT="http://127.0.0.1:9"',
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
write_executable(
|
||||
fake_bin / "curl",
|
||||
"""
|
||||
#!/bin/sh
|
||||
case "$*" in
|
||||
*127.0.0.1:9/json/version*)
|
||||
exit 7
|
||||
;;
|
||||
*)
|
||||
printf '%s\\n' '<html><title>Just a moment...</title><body>Checking your browser... Cloudflare</body></html>'
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
fake_bin / "node",
|
||||
"""
|
||||
#!/bin/sh
|
||||
printf '%s\\n' "$*" >> "$FAKE_LOG_DIR/node-args.log"
|
||||
output=""
|
||||
for arg in "$@"; do
|
||||
output="$arg"
|
||||
done
|
||||
printf '%s\\n' '<html><title>Steam Controller AppID: 4165870</title><body>Coming soon prerelease</body></html>' > "$output"
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
tmp_path / "bootstrap-steamdb.sh",
|
||||
f"#!/bin/sh\nprintf '%s\\n' bootstrap >> '{bootstrap_log}'\ncat > '{env_file}' <<'EOF'\nexport STEAMDB_PLAYWRIGHT_FALLBACK=1\nexport STEAMDB_PROFILE_DIR=\"{tmp_path / 'profile'}\"\nexport STEAMDB_CDP_ENDPOINT=\"http://127.0.0.1:55685\"\nEOF\n",
|
||||
)
|
||||
|
||||
env = os.environ.copy()
|
||||
env.update(
|
||||
{
|
||||
"PATH": f"{fake_bin}:{env['PATH']}",
|
||||
"FAKE_LOG_DIR": str(log_dir),
|
||||
"STEAMDB_ENV_FILE": str(env_file),
|
||||
"STEAMDB_BOOTSTRAP_CMD": str(tmp_path / "bootstrap-steamdb.sh"),
|
||||
}
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
[str(ROOT / "scripts" / "check_steamdb.sh"), str(run_dir)],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
self.assertTrue(bootstrap_log.exists())
|
||||
self.assertIn("bootstrap", bootstrap_log.read_text(encoding="utf-8"))
|
||||
|
||||
def test_records_reservation_package_update_baseline(self):
|
||||
tmp = TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
|
||||
@@ -70,6 +70,86 @@ IMPORTGENIUS_HTML = textwrap.dedent(
|
||||
)
|
||||
|
||||
|
||||
IMPORTGENIUS_CEVA_VR_HTML = textwrap.dedent(
|
||||
"""
|
||||
<html>
|
||||
<body>
|
||||
<h1>CEVA C/o Valve Corporation</h1>
|
||||
<p>Updated: 2026-06-10</p>
|
||||
<section>
|
||||
<h2>Importer Shipments</h2>
|
||||
<p># Bill of Lading Product Importer Supplier Arrival Date Country of Origin Gross Weight KGS Quantity</p>
|
||||
<p>1 SNHBSHACHI265173 VIRTUAL REALITY DEVICES CEVA C/O VALVE CORPORATION TECH-FRONT (CHONGQING) COMPUTER CO 2026-06-10 China 6374 Kgs 42 PKG</p>
|
||||
<p>2 SNHBSHACHI265174 VIRTUAL REALITY DEVICES CEVA C/O VALVE CORPORATION TECH-FRONT (CHONGQING) COMPUTER CO 2026-06-10 China 6372 Kgs 42 PKG</p>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
IMPORTGENIUS_VERTICAL_CEVA_VR_HTML = textwrap.dedent(
|
||||
"""
|
||||
<html>
|
||||
<body>
|
||||
<h1>CEVA C/o Valve Corporation</h1>
|
||||
<section>
|
||||
<h2>Importer Shipments</h2>
|
||||
<div>#</div><div>Bill of Lading</div><div>Product</div><div>Importer</div>
|
||||
<div>Supplier</div><div>Arrival Date</div><div>Country of Origin</div>
|
||||
<div>Gross Weight KGS</div><div>Quantity</div>
|
||||
<div>1</div>
|
||||
<div>SNHBSHACHI265173</div>
|
||||
<div>VIRTUAL REALITY DEVICES</div>
|
||||
<div>CEVA C/O VALVE CORPORATION</div>
|
||||
<div>TECH-FRONT (CHONGQING) COMPUTER CO</div>
|
||||
<div>2026-06-10</div>
|
||||
<div>China</div>
|
||||
<div>6374 Kgs</div>
|
||||
<div>42 PKG</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
IMPORTGENIUS_CEVA_NL_VR_HTML = textwrap.dedent(
|
||||
"""
|
||||
<html>
|
||||
<body>
|
||||
<h1>CEVA NL C/o Valve Corporation</h1>
|
||||
<p>Updated: 2026-06-10</p>
|
||||
<section>
|
||||
<h2>Importer Shipments</h2>
|
||||
<p># Bill of Lading Product Importer Supplier Arrival Date Country of Origin Gross Weight KGS Quantity</p>
|
||||
<p>1 SNHBSHALAX265177 VIRTUAL REALITY DEVICES CEVA NL C/O VALVE CORPORATION TECH-FRONT (CHONGQING) COMPUTER CO 2026-06-10 China 6400 Kgs 42 PKG</p>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
IMPORTGENIUS_VALVE_CONTROLLER_HTML = textwrap.dedent(
|
||||
"""
|
||||
<html>
|
||||
<body>
|
||||
<h1>Valve Corporation</h1>
|
||||
<p>Updated: 2026-06-10</p>
|
||||
<section>
|
||||
<h2>Importer Shipments</h2>
|
||||
<p># Bill of Lading Product Importer Supplier Arrival Date Country of Origin Gross Weight KGS Quantity</p>
|
||||
<p>1 SNHBHKGLBG266011 WIRELESS PC CONTROLLER VALVE CORPORATION CHENG UEI PRECISION IND. CO LTD 2026-06-10 Hong Kong 9727 Kgs 30 PKG</p>
|
||||
<p>4 DSVFMIL0341656 PNEUMATIC ACTUATOR VALVE 48 LLC L.P.S. SRL PER CONTO BIFFI ITALIA S 2026-05-16 Italy 1830 Kgs 1 CAS</p>
|
||||
<p>5 SNHBHKGLBG265013 WIRELESS PC CONTROLLER VALVE CORPORATION CHENG UEI PRECISION IND. CO LTD 2026-05-12 Hong Kong 12970 Kgs 40 PKG</p>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def run_parser(args, reports):
|
||||
return subprocess.run(
|
||||
[
|
||||
@@ -289,6 +369,74 @@ class CustomsShipmentParserTests(unittest.TestCase):
|
||||
self.assertIn("SNHBSHACHI265020", key_lines)
|
||||
self.assertIn("2026-05-18", key_lines)
|
||||
|
||||
def test_extracts_importgenius_virtual_reality_device_rows(self):
|
||||
with TemporaryDirectory() as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
ceva = tmp_path / "importgenius-ceva.html"
|
||||
ceva_nl = tmp_path / "importgenius-ceva-nl.html"
|
||||
ceva.write_text(IMPORTGENIUS_CEVA_VR_HTML, encoding="utf-8")
|
||||
ceva_nl.write_text(IMPORTGENIUS_CEVA_NL_VR_HTML, encoding="utf-8")
|
||||
reports = tmp_path / "reports"
|
||||
|
||||
result = run_parser(
|
||||
[
|
||||
"--input",
|
||||
f"importgenius-ceva-valve={ceva}",
|
||||
"--input",
|
||||
f"importgenius-ceva-nl-valve={ceva_nl}",
|
||||
],
|
||||
reports,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
rows = read_rows(reports)
|
||||
self.assertEqual(
|
||||
["SNHBSHACHI265173", "SNHBSHACHI265174", "SNHBSHALAX265177"],
|
||||
[row["house_bol"] for row in rows],
|
||||
)
|
||||
self.assertTrue(
|
||||
all(row["commodity"] == "VIRTUAL REALITY DEVICES" for row in rows)
|
||||
)
|
||||
self.assertEqual("CEVA C/O VALVE CORPORATION", rows[0]["consignee"])
|
||||
self.assertEqual("CEVA NL C/O VALVE CORPORATION", rows[2]["consignee"])
|
||||
|
||||
def test_extracts_importgenius_vertical_table_rows(self):
|
||||
with TemporaryDirectory() as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
html = tmp_path / "importgenius-ceva-vertical.html"
|
||||
html.write_text(IMPORTGENIUS_VERTICAL_CEVA_VR_HTML, encoding="utf-8")
|
||||
reports = tmp_path / "reports"
|
||||
|
||||
result = run_parser(["--input", f"importgenius-ceva-valve={html}"], reports)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
rows = read_rows(reports)
|
||||
self.assertEqual(["SNHBSHACHI265173"], [row["house_bol"] for row in rows])
|
||||
self.assertEqual("VIRTUAL REALITY DEVICES", rows[0]["commodity"])
|
||||
self.assertEqual("6374 Kgs", rows[0]["weight"])
|
||||
|
||||
def test_extracts_importgenius_wireless_pc_controller_rows(self):
|
||||
with TemporaryDirectory() as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
html = tmp_path / "importgenius-valve-corp.html"
|
||||
html.write_text(IMPORTGENIUS_VALVE_CONTROLLER_HTML, encoding="utf-8")
|
||||
reports = tmp_path / "reports"
|
||||
|
||||
result = run_parser(["--input", f"importgenius-valve-corp={html}"], reports)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
rows = read_rows(reports)
|
||||
self.assertEqual(
|
||||
["SNHBHKGLBG266011", "SNHBHKGLBG265013"],
|
||||
[row["house_bol"] for row in rows],
|
||||
)
|
||||
self.assertEqual("WIRELESS PC CONTROLLER", rows[0]["commodity"])
|
||||
self.assertEqual("VALVE CORPORATION", rows[0]["consignee"])
|
||||
self.assertEqual("CHENG UEI PRECISION IND. CO LTD", rows[0]["shipper"])
|
||||
|
||||
|
||||
class CheckCustomsShipmentsShellTests(unittest.TestCase):
|
||||
def test_fetches_pages_and_runs_parser(self):
|
||||
@@ -458,6 +606,76 @@ class CheckCustomsShipmentsShellTests(unittest.TestCase):
|
||||
).read_text(encoding="utf-8")
|
||||
self.assertIn("SNHBSHACHI265020", key_lines)
|
||||
|
||||
def test_fetches_additional_importgenius_valve_importer_pages(self):
|
||||
with TemporaryDirectory() as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
run_dir = tmp_path / "run"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
(tmp_path / "importgenius-ingram-fixture.html").write_text(
|
||||
IMPORTGENIUS_HTML, encoding="utf-8"
|
||||
)
|
||||
(tmp_path / "importgenius-ceva-fixture.html").write_text(
|
||||
IMPORTGENIUS_CEVA_VR_HTML, encoding="utf-8"
|
||||
)
|
||||
(tmp_path / "importgenius-ceva-nl-fixture.html").write_text(
|
||||
IMPORTGENIUS_CEVA_NL_VR_HTML, encoding="utf-8"
|
||||
)
|
||||
(tmp_path / "importgenius-valve-corp-fixture.html").write_text(
|
||||
IMPORTGENIUS_VALVE_CONTROLLER_HTML, encoding="utf-8"
|
||||
)
|
||||
write_executable(
|
||||
fake_bin / "curl",
|
||||
f"""
|
||||
#!/bin/sh
|
||||
for arg do
|
||||
url="$arg"
|
||||
done
|
||||
case "$url" in
|
||||
*importgenius.com/importers/ingram-micro-c-o-valve-corporation)
|
||||
cat "{tmp_path / "importgenius-ingram-fixture.html"}"
|
||||
;;
|
||||
*importgenius.com/importers/ceva-c-o-valve-corporation)
|
||||
cat "{tmp_path / "importgenius-ceva-fixture.html"}"
|
||||
;;
|
||||
*importgenius.com/importers/ceva-nl-c-o-valve-corporation)
|
||||
cat "{tmp_path / "importgenius-ceva-nl-fixture.html"}"
|
||||
;;
|
||||
*importgenius.com/importers/valve-corp)
|
||||
cat "{tmp_path / "importgenius-valve-corp-fixture.html"}"
|
||||
;;
|
||||
*)
|
||||
exit 22
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = f"{fake_bin}{os.pathsep}{env['PATH']}"
|
||||
|
||||
result = subprocess.run(
|
||||
[str(ROOT / "scripts" / "check_customs_shipments.sh"), str(run_dir)],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
customs_dir = run_dir / "api" / "customs"
|
||||
self.assertTrue((customs_dir / "importgenius-ceva-valve.html").exists())
|
||||
self.assertTrue((customs_dir / "importgenius-ceva-nl-valve.html").exists())
|
||||
self.assertTrue((customs_dir / "importgenius-valve-corp.html").exists())
|
||||
key_lines = (
|
||||
run_dir / "reports" / "customs-shipments-key-lines.txt"
|
||||
).read_text(encoding="utf-8")
|
||||
self.assertIn("SNHBSHACHI265173", key_lines)
|
||||
self.assertIn("SNHBSHALAX265177", key_lines)
|
||||
self.assertIn("SNHBHKGLBG266011", key_lines)
|
||||
|
||||
|
||||
class CustomsSummaryIntegrationTests(unittest.TestCase):
|
||||
def test_run_summary_and_status_draft_include_customs_lines(self):
|
||||
|
||||
@@ -176,6 +176,170 @@ class CheckSteamVRDepotsTests(unittest.TestCase):
|
||||
self.assertIn("Steam Frame", key_lines)
|
||||
self.assertIn("Deckard", key_lines)
|
||||
|
||||
def test_uses_steamdb_playwright_fallback_for_depot_page(self):
|
||||
tmp = TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
tmp_path = Path(tmp.name)
|
||||
run_dir = tmp_path / "run"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
log_dir = tmp_path / "logs"
|
||||
log_dir.mkdir()
|
||||
|
||||
write_executable(
|
||||
fake_bin / "curl",
|
||||
"""
|
||||
#!/bin/sh
|
||||
for arg in "$@"; do
|
||||
url="$arg"
|
||||
done
|
||||
case "$url" in
|
||||
*steamdb.info*)
|
||||
printf '%s\\n' '<html><title>Just a moment...</title><body>Checking your browser Cloudflare</body></html>'
|
||||
;;
|
||||
*ISteamNews*)
|
||||
printf '%s\\n' '{"appnews":{"appid":250820,"newsitems":[]}}'
|
||||
;;
|
||||
*)
|
||||
echo "unexpected url: $url" >&2
|
||||
exit 22
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
fake_bin / "node",
|
||||
"""
|
||||
#!/bin/sh
|
||||
printf '%s\\n' "$*" >> "$FAKE_LOG_DIR/node-args.log"
|
||||
output=""
|
||||
for arg in "$@"; do
|
||||
output="$arg"
|
||||
done
|
||||
printf '%s\\n' '<html><body><table><tr><td>250823</td><td>Linux OpenVR Linux</td></tr><tr><td>Build ID</td><td>123</td></tr><tr><td>public</td><td>Steam Frame depot note</td></tr></table></body></html>' > "$output"
|
||||
""",
|
||||
)
|
||||
|
||||
env = os.environ.copy()
|
||||
env.update(
|
||||
{
|
||||
"PATH": f"{fake_bin}:{env['PATH']}",
|
||||
"FAKE_LOG_DIR": str(log_dir),
|
||||
"STEAMDB_PLAYWRIGHT_FALLBACK": "1",
|
||||
"STEAMDB_AUTO_BOOTSTRAP": "0",
|
||||
}
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
[str(ROOT / "scripts" / "check_steamvr_depots.sh"), str(run_dir)],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
self.assertTrue((log_dir / "node-args.log").exists())
|
||||
self.assertTrue((run_dir / "api" / "steamvr-depots" / "steamdb-depots.html").exists())
|
||||
errors = (run_dir / "reports" / "steamvr-depots-errors.txt").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
key_lines = (run_dir / "reports" / "steamvr-depots-key-lines.txt").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
self.assertEqual("", errors)
|
||||
self.assertIn("Steam Frame", key_lines)
|
||||
|
||||
def test_steamdb_playwright_fallback_bootstraps_when_cdp_is_stale(self):
|
||||
tmp = TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
tmp_path = Path(tmp.name)
|
||||
run_dir = tmp_path / "run"
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
log_dir = tmp_path / "logs"
|
||||
log_dir.mkdir()
|
||||
env_file = tmp_path / "steamdb-env.sh"
|
||||
bootstrap_log = tmp_path / "bootstrap.log"
|
||||
|
||||
env_file.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"export STEAMDB_PLAYWRIGHT_FALLBACK=1",
|
||||
f'export STEAMDB_PROFILE_DIR="{tmp_path / "profile"}"',
|
||||
'export STEAMDB_CDP_ENDPOINT="http://127.0.0.1:9"',
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
write_executable(
|
||||
fake_bin / "curl",
|
||||
"""
|
||||
#!/bin/sh
|
||||
case "$*" in
|
||||
*127.0.0.1:9/json/version*)
|
||||
exit 7
|
||||
;;
|
||||
*steamdb.info*)
|
||||
printf '%s\\n' '<html><title>Just a moment...</title><body>Checking your browser Cloudflare</body></html>'
|
||||
;;
|
||||
*ISteamNews*)
|
||||
printf '%s\\n' '{"appnews":{"appid":250820,"newsitems":[]}}'
|
||||
;;
|
||||
*)
|
||||
echo "unexpected args: $*" >&2
|
||||
exit 22
|
||||
;;
|
||||
esac
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
fake_bin / "node",
|
||||
"""
|
||||
#!/bin/sh
|
||||
printf '%s\\n' "$*" >> "$FAKE_LOG_DIR/node-args.log"
|
||||
output=""
|
||||
for arg in "$@"; do
|
||||
output="$arg"
|
||||
done
|
||||
printf '%s\\n' '<html><body><table><tr><td>public</td><td>Steam Frame depot note</td></tr></table></body></html>' > "$output"
|
||||
""",
|
||||
)
|
||||
write_executable(
|
||||
tmp_path / "bootstrap-steamdb.sh",
|
||||
f"#!/bin/sh\nprintf '%s\\n' bootstrap >> '{bootstrap_log}'\ncat > '{env_file}' <<'EOF'\nexport STEAMDB_PLAYWRIGHT_FALLBACK=1\nexport STEAMDB_PROFILE_DIR=\"{tmp_path / 'profile'}\"\nexport STEAMDB_CDP_ENDPOINT=\"http://127.0.0.1:55685\"\nEOF\n",
|
||||
)
|
||||
|
||||
env = os.environ.copy()
|
||||
env.update(
|
||||
{
|
||||
"PATH": f"{fake_bin}:{env['PATH']}",
|
||||
"FAKE_LOG_DIR": str(log_dir),
|
||||
"STEAMDB_ENV_FILE": str(env_file),
|
||||
"STEAMDB_BOOTSTRAP_CMD": str(tmp_path / "bootstrap-steamdb.sh"),
|
||||
}
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
[str(ROOT / "scripts" / "check_steamvr_depots.sh"), str(run_dir)],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual("", result.stderr)
|
||||
self.assertEqual(0, result.returncode)
|
||||
self.assertTrue(bootstrap_log.exists())
|
||||
self.assertTrue((log_dir / "node-args.log").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user