oterm/tests/widgets/test_caps.py
Yiorgis Gozadinos 0fdd7db25d
Bump pydantic-ai to 2.51.0 and drop Python 3.10
pydantic-ai-slim 2.37.0 -> 2.51.0 and pydantic-ai-harness 0.28.0 ->
0.36.0, which includes the 2.44.0 web_fetch fixes (a hostile page could
stall the event loop). ruff 0.16.9, ty 0.0.84, full lock refresh.
pytest-textual-snapshot stays at 1.0.0: 1.1.0 pins syrupy 4.8.0, which
requires pytest<9.

Python 3.10 reaches end of life in October; requires-python is now
>=3.11, so the speak extra no longer needs its version marker.

ty 0.0.84 rejects assigning a function to a model instance's
request_stream, so the file-aware test model is now a FunctionModel
subclass.
2026-09-26 15:51:22 +03:00

54 lines
1.6 KiB
Python

from textual.app import App, ComposeResult
from textual.widgets import Label
from oterm.app.widgets.caps import Capabilities
class _Host(App):
def compose(self) -> ComposeResult:
yield Capabilities(id="caps")
async def test_initial_caps_render_as_emoji_labels():
app = _Host()
async with app.run_test() as pilot:
caps = app.query_one(Capabilities)
caps.caps = ["tools", "vision", "thinking"]
await pilot.pause()
texts = {str(label.content) for label in caps.query(Label)}
assert {"🛠️", "👁️", "🧠"}.issubset(texts)
async def test_caps_update_replaces_previous_labels():
app = _Host()
async with app.run_test() as pilot:
caps = app.query_one(Capabilities)
caps.caps = ["tools", "vision"]
await pilot.pause()
assert len(list(caps.query(Label))) == 2
caps.caps = ["thinking"]
await pilot.pause()
labels = list(caps.query(Label))
assert len(labels) == 1
assert str(labels[0].content) == "🧠"
async def test_empty_caps_renders_no_labels():
app = _Host()
async with app.run_test() as pilot:
caps = app.query_one(Capabilities)
caps.caps = []
await pilot.pause()
assert list(caps.query(Label)) == []
async def test_tooltip_is_the_capability_name():
app = _Host()
async with app.run_test() as pilot:
caps = app.query_one(Capabilities)
caps.caps = ["tools"]
await pilot.pause()
label = list(caps.query(Label))[0]
assert label.tooltip == "tools"