litellm/tests/local_testing/test_get_model_file.py
Chesars 88ee7c507b refactor: Remove redundant backup file for model pricing
- Removed litellm/model_prices_and_context_window_backup.json
- Updated get_model_cost_map() to read from single source
- Refactored _load_local_model_cost_map() to support:
  * Package resources (production/pip install)
  * Project root (development)
- Updated CI/CD workflows:
  * .circleci/config.yml: Copy to litellm/ before publishing
  * .github/workflows/simple_pypi_publish.yml: Same approach
  * ci_cd/check_files_match.py: Updated file paths
- Updated test_get_model_file.py to use project root
- Renamed test_get_backup_model_cost_map → test_get_local_model_cost_map

Benefits:
- Eliminates file duplication
- Single source of truth for model pricing
- No need for PRs like #16460 to sync backup files
- Simpler maintenance

The backup was unnecessary because CI copies the file to the package before publishing.
2025-11-13 12:43:25 -03:00

33 lines
917 B
Python

import os, sys, traceback
import importlib.resources
import json
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
import litellm
import pytest
def test_get_model_cost_map():
try:
print(litellm.get_model_cost_map(url="fake-url"))
except Exception as e:
pytest.fail(f"An exception occurred: {e}")
def test_get_local_model_cost_map():
"""Test that we can load the local model cost map"""
from pathlib import Path
# Test loading from project root (development scenario)
project_root = Path(__file__).parent.parent.parent
model_cost_map_path = project_root / "model_prices_and_context_window.json"
with open(model_cost_map_path, "r") as f:
print("inside local model cost map")
content = json.load(f)
print("content", content)
assert content is not None
assert len(content) > 0