aboutsummaryrefslogtreecommitdiffstats
path: root/test_llamachat.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-10 18:31:51 +0200
committerDanilo M. <danix@danix.xyz>2026-08-10 18:31:51 +0200
commita7dd41385baa8f3ac34deda827f0344f82fb713e (patch)
tree0760cfd549779a7d118ecff3de2a934ca8a7f2bd /test_llamachat.py
parentc8d3298e1bb6a9245449dac1c8727ce3d932cd1d (diff)
downloadllamachat-a7dd41385baa8f3ac34deda827f0344f82fb713e.tar.gz
llamachat-a7dd41385baa8f3ac34deda827f0344f82fb713e.zip
feat: cost label showing spend and the next send's projection
Three states stay distinct: blank for a free local model, ? for a cloud model whose prices were never entered, and a figure when they were. Collapsing the first two would make an unpriced cloud model read as free. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'test_llamachat.py')
-rwxr-xr-xtest_llamachat.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test_llamachat.py b/test_llamachat.py
index b561b66..18b6f0a 100755
--- a/test_llamachat.py
+++ b/test_llamachat.py
@@ -2025,6 +2025,36 @@ def test_model_dialog_values():
print("ok model dialog value conversion")
+def test_cost_label_text():
+ """The label distinguishes free, unpriced, and a real figure."""
+ from llamachat import ui
+
+ # A local model costs nothing, so the label says nothing.
+ assert ui.cost_text(spent=0.0, projected=0.0, billable=False, priced=False) == ""
+
+ # A cloud model whose price was never entered: ? rather than blank, so
+ # it cannot be mistaken for free.
+ assert ui.cost_text(
+ spent=0.0, projected=0.0, billable=True, priced=False
+ ) == "?"
+
+ # Spent so far, with nothing composed yet.
+ assert ui.cost_text(
+ spent=0.043, projected=0.0, billable=True, priced=True
+ ) == "$0.043"
+
+ # Spent plus what sending the draft would add, kept visually separate.
+ assert ui.cost_text(
+ spent=0.043, projected=0.011, billable=True, priced=True
+ ) == "$0.043 +$0.011"
+
+ # A fresh conversation on a priced model still shows the projection.
+ assert ui.cost_text(
+ spent=0.0, projected=0.002, billable=True, priced=True
+ ) == "$0.000 +$0.002"
+ print("ok cost label text")
+
+
class _FakeResponse:
"""Enough of an http.client response for urlopen's context manager."""
@@ -2788,6 +2818,7 @@ if __name__ == "__main__":
test_client_auth_header()
test_multi_client()
test_model_dialog_values()
+ test_cost_label_text()
test_search_tool_schema()
test_search_results_sanitising()
test_tool_call_accumulation()