by adom
Publish molecule sources to the Adom wiki (STEP, board, schematic, <slug>-fab.zip, export.json); the wiki's 3D model registry builds the GLB, footprint and symbol. Checks the bundle the way the registry does, publishes private, waits for the build, sets the hero from the built model, then makes the page public. Board mode still converts plain boards. Also writes APM render assets and component dependencies. Companion to adom-wiki model import.
master
AdityaAngajala
Preserve source for molecule-publish-3.0.0
33f54d8
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
"""versions_check.py: the 8.2 messages of the molecule contract; run with unittest."""
import contextlib
import importlib.util
import io
import json
import subprocess
import tempfile
import unittest
from pathlib import Path
from unittest import mock
SCRIPT = Path(__file__).resolve().parents[1] / "scripts/versions_check.py"
spec = importlib.util.spec_from_file_location("versions_check", SCRIPT)
vc = importlib.util.module_from_spec(spec)
spec.loader.exec_module(vc)
def runner(outputs):
return lambda cmd: outputs.get(" ".join(cmd))
class VersionsCheckTests(unittest.TestCase):
def test_cli_older_than_1_8_0_gets_the_contract_message(self):
r = vc.check_cli(runner({"adom-wiki --version": "adom-wiki 1.7.72\n"}))
self.assertFalse(r["ok"])
self.assertEqual(r["message"], "This skill needs adom-wiki 1.8.0 or newer (found 1.7.72). Run: adom-wiki self-update")
def test_cli_1_8_0_with_model_verbs_passes(self):
r = vc.check_cli(runner({"adom-wiki --version": "adom-wiki 1.8.0", "adom-wiki model --help": "model: builds history plan"}))
self.assertTrue(r["ok"])
def test_unknown_command_model_counts_as_outdated(self):
r = vc.check_cli(runner({"adom-wiki --version": "adom-wiki 1.8.0",
"adom-wiki model --help": "error: 'model' is not an adom-wiki command"}))
self.assertFalse(r["ok"])
self.assertIn("found 1.8.0", r["message"])
def test_missing_cli_stops(self):
r = vc.check_cli(runner({}))
self.assertFalse(r["ok"])
self.assertTrue(r["message"].startswith("This skill needs adom-wiki 1.8.0 or newer (found none). Run: adom-wiki self-update"))
def test_runs_only_adom_wiki(self):
seen = []
def fake_run(cmd, **kwargs):
seen.append(cmd[0])
out = "adom-wiki 1.8.0" if cmd[1:] == ["--version"] else "model: builds history plan"
return subprocess.CompletedProcess(cmd, 0, out, "")
with tempfile.TemporaryDirectory() as d, \
mock.patch.object(vc.subprocess, "run", fake_run), \
mock.patch.object(vc.Path, "home", return_value=Path(d)), \
contextlib.redirect_stdout(io.StringIO()) as out:
self.assertEqual(vc.main(["--json"]), 0)
self.assertEqual(set(seen), {"adom-wiki"})
self.assertEqual(set(json.loads(out.getvalue())), {"cli", "exporters"})
def test_installed_exporters_older_than_their_release(self):
with tempfile.TemporaryDirectory() as d:
skills = Path(d)
(skills / "kicad-export-molecule").mkdir() # 1.2.0 installs no package.json
(skills / "fusion-export-molecule").mkdir()
(skills / "fusion-export-molecule" / "package.json").write_text(json.dumps({"version": "2.0.0"}))
(skills / "altium-export-molecule").mkdir()
(skills / "altium-export-molecule" / "package.json").write_text(json.dumps({"version": "2.4.0"}))
rows = {r["name"]: r for r in vc.check_exporters(skills)}
self.assertEqual(set(rows), {"kicad-export-molecule", "fusion-export-molecule", "altium-export-molecule"})
self.assertEqual(rows["kicad-export-molecule"]["message"],
"Update adom/kicad-export-molecule to 2.0.0: adom-wiki pkg install adom/kicad-export-molecule")
self.assertTrue(rows["fusion-export-molecule"]["ok"])
self.assertEqual(rows["altium-export-molecule"]["message"],
"Update adom/altium-export-molecule to 3.0.0: adom-wiki pkg install adom/altium-export-molecule")
def test_versions_compare_numerically(self):
self.assertFalse(vc.older("1.10.0", "1.8.0"))
self.assertTrue(vc.older("1.7.99", "1.8.0"))
self.assertTrue(vc.older(None, "1.8.0"))
if __name__ == "__main__":
unittest.main()