personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4import platform
5import sys
6
7import pytest
8
9import solstone.observe.transcribe.parakeet as parakeet
10
11
12def test_dispatch_transcribe_routes_darwin_arm64(monkeypatch: pytest.MonkeyPatch):
13 monkeypatch.setattr(sys, "platform", "darwin")
14 monkeypatch.setattr(platform, "machine", lambda: "arm64")
15 monkeypatch.setattr(
16 parakeet._parakeet_coreml,
17 "transcribe",
18 lambda *args, **kwargs: [{"arm": "coreml"}],
19 )
20 monkeypatch.setattr(
21 parakeet._parakeet_cpp, "transcribe", lambda *args, **kwargs: [{"arm": "cpp"}]
22 )
23
24 assert parakeet.transcribe([], 16000, {}) == [{"arm": "coreml"}]
25
26
27@pytest.mark.parametrize("arch", ["x86_64", "aarch64"])
28def test_dispatch_transcribe_routes_linux(monkeypatch: pytest.MonkeyPatch, arch: str):
29 monkeypatch.setattr(sys, "platform", "linux")
30 monkeypatch.setattr(platform, "machine", lambda: arch)
31 monkeypatch.setattr(
32 parakeet._parakeet_coreml,
33 "transcribe",
34 lambda *args, **kwargs: [{"arm": "coreml"}],
35 )
36 monkeypatch.setattr(
37 parakeet._parakeet_cpp, "transcribe", lambda *args, **kwargs: [{"arm": "cpp"}]
38 )
39
40 assert parakeet.transcribe([], 16000, {}) == [{"arm": "cpp"}]
41
42
43@pytest.mark.parametrize(
44 ("os_name", "arch", "expected"),
45 [
46 ("darwin", "x86_64", "darwin/x86_64"),
47 ("linux", "riscv64", "linux/riscv64"),
48 ("win32", "AMD64", "win32/amd64"),
49 ],
50)
51def test_dispatch_transcribe_unsupported_platforms_raise(
52 monkeypatch: pytest.MonkeyPatch,
53 os_name: str,
54 arch: str,
55 expected: str,
56):
57 monkeypatch.setattr(sys, "platform", os_name)
58 monkeypatch.setattr(platform, "machine", lambda: arch)
59
60 with pytest.raises(RuntimeError, match="Supported platforms"):
61 parakeet.transcribe([], 16000, {})
62
63 with pytest.raises(RuntimeError) as exc_info:
64 parakeet.transcribe([], 16000, {})
65
66 message = str(exc_info.value)
67 assert expected in message
68 assert "darwin/arm64" in message
69 assert "linux/x86_64" in message
70 assert "linux/aarch64" in message
71
72
73def test_dispatch_get_model_info_routes_linux_x86_64(
74 monkeypatch: pytest.MonkeyPatch,
75):
76 monkeypatch.setattr(sys, "platform", "linux")
77 monkeypatch.setattr(platform, "machine", lambda: "x86_64")
78 monkeypatch.setattr(
79 parakeet._parakeet_cpp, "get_model_info", lambda config: {"arm": "cpp"}
80 )
81
82 assert parakeet.get_model_info({}) == {"arm": "cpp"}