Skip to content

Commit

Permalink
fix: unit test should not call private function (microsoft#1494)
Browse files Browse the repository at this point in the history
* fix: unit test should not call private function

* fix test

* restore config
  • Loading branch information
olgavrou authored Jan 31, 2024
1 parent 2a271ce commit 71c49da
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/oai/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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():
Expand Down

0 comments on commit 71c49da

Please sign in to comment.