forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_desktop_profile.py
More file actions
65 lines (44 loc) · 2.23 KB
/
Copy pathtest_desktop_profile.py
File metadata and controls
65 lines (44 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from __future__ import annotations
import sys
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from dev_harness import config, desktop_profile
REPO_ROOT = Path(__file__).resolve().parents[3]
def _resolve(user_env: dict[str, str] | None = None) -> desktop_profile.DesktopLocalProfile:
env = {"OMI_LOCAL_STATE_ROOT": str(REPO_ROOT / ".local-harness-state")}
if user_env:
env.update(user_env)
cfg = config.load_config(REPO_ROOT, env=env, create_layout=False)
return desktop_profile.resolve_profile(cfg, user="alice", seeded_users=("alice",), env=env)
def test_validate_profile_blocks_default_omi_dev() -> None:
profile = _resolve()
assert profile.app_name == desktop_profile.LOCAL_APP_NAME
assert profile.bundle_id == desktop_profile.LOCAL_BUNDLE_ID
errors = desktop_profile.validate_profile(profile)
assert errors
assert any(desktop_profile.LOCAL_PROFILE_OMI_DEV_BLOCKED in error for error in errors)
def test_validate_profile_allows_omi_memory_named_bundle() -> None:
profile = _resolve({"OMI_APP_NAME": "omi-memory"})
assert profile.app_name == "omi-memory"
assert profile.bundle_id == "com.omi.omi-memory"
errors = desktop_profile.validate_profile(profile)
assert not errors
def test_named_bundle_automation_uses_supplied_environment(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("OMI_ENABLE_LOCAL_AUTOMATION", "ambient-disabled")
monkeypatch.setenv("OMI_AUTOMATION_PORT", "9999")
profile = _resolve(
{
"OMI_APP_NAME": "omi-memory",
"OMI_ENABLE_LOCAL_AUTOMATION": "explicit-enabled",
"OMI_AUTOMATION_PORT": "8765",
}
)
assert profile.env["OMI_ENABLE_LOCAL_AUTOMATION"] == "explicit-enabled"
assert profile.env["OMI_AUTOMATION_PORT"] == "8765"
def test_named_bundle_automation_defaults_ignore_ambient_environment(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("OMI_ENABLE_LOCAL_AUTOMATION", "ambient-disabled")
monkeypatch.setenv("OMI_AUTOMATION_PORT", "9999")
profile = _resolve({"OMI_APP_NAME": "omi-memory"})
assert profile.env["OMI_ENABLE_LOCAL_AUTOMATION"] == "1"
assert "OMI_AUTOMATION_PORT" not in profile.env