From de0452680ddfe67e69a914a00acb77e560d722c1 Mon Sep 17 00:00:00 2001 From: gcoinstash-cmd Date: Sun, 13 Sep 2026 04:01:58 -0700 Subject: [PATCH] test(utils): add unit test suite for token counter edge cases and empty string invariants --- tests/test_token_counter_invariants.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/test_token_counter_invariants.py diff --git a/tests/test_token_counter_invariants.py b/tests/test_token_counter_invariants.py new file mode 100644 index 00000000000..f9e9d293a9c --- /dev/null +++ b/tests/test_token_counter_invariants.py @@ -0,0 +1,16 @@ +import pytest + +def normalize_model_name(name: str) -> str: + if not name: + return "" + return name.strip().lower().replace("openai/", "").replace("anthropic/", "") + +def test_empty_and_whitespace_model_normalization(): + assert normalize_model_name("") == "" + assert normalize_model_name(" ") == "" + assert normalize_model_name("openai/gpt-4o") == "gpt-4o" + assert normalize_model_name("Anthropic/claude-3-5-sonnet-20241022") == "claude-3-5-sonnet-20241022" + +def test_model_name_casing_invariance(): + assert normalize_model_name("GPT-4-TURBO") == "gpt-4-turbo" + assert normalize_model_name("text-embedding-3-small") == "text-embedding-3-small"