From 03f165ce81e6e01bb449622edd6b4fbed027fe29 Mon Sep 17 00:00:00 2001 From: olgavrou Date: Wed, 31 Jan 2024 23:31:45 +0200 Subject: [PATCH] fix: unit test should not call private function (#1494) * fix: unit test should not call private function * fix test * restore config --- test/oai/test_client.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/oai/test_client.py b/test/oai/test_client.py index b8c93e13d707..77b69cb71cad 100644 --- a/test/oai/test_client.py +++ b/test/oai/test_client.py @@ -138,12 +138,6 @@ def test_usage_summary(): # check print client.print_usage_summary() - # check update - client._update_usage_summary(response, use_cache=True) - assert ( - client.total_usage_summary["total_cost"] == response.cost * 2 - ), "total_cost should be equal to response.cost * 2" - # check clear client.clear_usage_summary() assert client.actual_usage_summary is None, "actual_usage_summary should be None" @@ -152,8 +146,16 @@ def test_usage_summary(): # actual usage and all usage should be different response = client.create(prompt="1+3=", model=model, cache_seed=42) assert client.total_usage_summary["total_cost"] > 0, "total_cost should be greater than 0" + client.clear_usage_summary() + response = client.create(prompt="1+3=", model=model, cache_seed=42) assert client.actual_usage_summary is None, "No actual cost should be recorded" + # check update + response = client.create(prompt="1+3=", model=model, cache_seed=42) + assert ( + client.total_usage_summary["total_cost"] == response.cost * 2 + ), "total_cost should be equal to response.cost * 2" + @pytest.mark.skipif(skip, reason="openai>=1 not installed") def test_legacy_cache():