Python parity for the 5 personality voice commands shipped on the
Rust side:
- New `personality_handlers.py` (~150 lines): do_personality_{greet,
thanks, compliment, how_are_you, tony_quote}. Each picks one of
7-10 phrases per language (RU/EN) at random; greet additionally
buckets by time-of-day (morning/midday/evening/night).
- `extensions.py`: imports + 5 proxy `do_personality_*` functions
pointing at the new module, plus set_speak wiring so handlers can
TTS via the runtime's voice.
- `main.py`: 5 new dispatch elifs feeding the new action types.
- `commands.yaml`: 5 new entries (`personality_*`) mapping voice
phrases to action types.
- `tests/test_personality_handlers.py`: 6 unit tests confirming
each handler returns a non-empty string from the expected pool.
- `.gitignore`: stop tracking runtime state generated by tests
(profiles/, long_term_memory.json, schedule.json, macros.json,
llm_backend.txt, llm_history.json) — these are user data, not
source.
Tests: 54 → 60 (+6).
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
"""Tests for personality_handlers — picks vary, speak is invoked."""
|
|
|
|
import importlib
|
|
import sys
|
|
|
|
|
|
def _fresh_module(monkeypatch):
|
|
if 'personality_handlers' in sys.modules:
|
|
del sys.modules['personality_handlers']
|
|
return importlib.import_module('personality_handlers')
|
|
|
|
|
|
def test_greet_speaks_something(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
spoken = []
|
|
mod.set_speak(lambda t: spoken.append(t))
|
|
mod.do_personality_greet({}, '')
|
|
assert len(spoken) == 1
|
|
assert isinstance(spoken[0], str)
|
|
assert len(spoken[0]) > 0
|
|
|
|
|
|
def test_greet_bucket_thresholds(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
assert mod._greet_bucket(7) is mod._GREET_MORNING
|
|
assert mod._greet_bucket(13) is mod._GREET_MIDDAY
|
|
assert mod._greet_bucket(19) is mod._GREET_EVENING
|
|
assert mod._greet_bucket(2) is mod._GREET_NIGHT
|
|
assert mod._greet_bucket(23) is mod._GREET_NIGHT
|
|
|
|
|
|
def test_thanks_returns_from_pool(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
spoken = []
|
|
mod.set_speak(lambda t: spoken.append(t))
|
|
mod.do_personality_thanks({}, '')
|
|
assert spoken[0] in mod._THANKS
|
|
|
|
|
|
def test_tony_quote_returns_from_pool(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
spoken = []
|
|
mod.set_speak(lambda t: spoken.append(t))
|
|
mod.do_personality_tony_quote({}, '')
|
|
assert spoken[0] in mod._TONY_QUOTES
|
|
|
|
|
|
def test_compliment_returns_from_pool(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
spoken = []
|
|
mod.set_speak(lambda t: spoken.append(t))
|
|
mod.do_personality_compliment({}, '')
|
|
assert spoken[0] in mod._COMPLIMENT
|
|
|
|
|
|
def test_how_are_you_speaks(monkeypatch):
|
|
mod = _fresh_module(monkeypatch)
|
|
spoken = []
|
|
mod.set_speak(lambda t: spoken.append(t))
|
|
mod.do_personality_how_are_you({}, '')
|
|
assert len(spoken) == 1
|
|
assert len(spoken[0]) > 0
|