Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Cyprien <courtot.c@gmail.com> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: josephine-delas <57808586+josephine-delas@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from vibe.cli.textual_ui.widgets.context_progress import ContextProgress, TokenState
|
|
|
|
|
|
def test_context_progress_shows_percentage_when_empty() -> None:
|
|
widget = ContextProgress()
|
|
|
|
widget.watch_tokens(TokenState(max_tokens=200_000, current_tokens=0))
|
|
|
|
assert str(widget.render()) == "0/200k tokens (0%)"
|
|
|
|
|
|
def test_context_progress_uses_compact_integer_format_for_used_tokens() -> None:
|
|
widget = ContextProgress()
|
|
|
|
widget.watch_tokens(TokenState(max_tokens=200_000, current_tokens=12_500))
|
|
|
|
assert str(widget.render()) == "12k/200k tokens (6%)"
|
|
|
|
|
|
def test_context_progress_uses_compact_integer_k_format() -> None:
|
|
widget = ContextProgress()
|
|
|
|
widget.watch_tokens(TokenState(max_tokens=568_000, current_tokens=170_000))
|
|
|
|
assert str(widget.render()) == "170k/568k tokens (30%)"
|
|
|
|
|
|
def test_context_progress_uses_compact_integer_m_format() -> None:
|
|
widget = ContextProgress()
|
|
|
|
widget.watch_tokens(TokenState(max_tokens=40_000_000, current_tokens=35_900_000))
|
|
|
|
assert str(widget.render()) == "35.9M/40.0M tokens (90%)"
|