mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Add test for Router.get_valid_args, fix router code coverage encoding
- Add test_get_valid_args in test_router_helper_utils.py to cover get_valid_args - Use encoding='utf-8' in router_code_coverage.py for cross-platform file reads
This commit is contained in:
parent
de3bbc216d
commit
8d1bb2ad6d
2 changed files with 31 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ def get_function_names_from_file(file_path):
|
|||
"""
|
||||
Extracts all function names from a given Python file.
|
||||
"""
|
||||
with open(file_path, "r") as file:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
tree = ast.parse(file.read())
|
||||
|
||||
function_names = []
|
||||
|
|
@ -45,7 +45,7 @@ def get_all_functions_called_in_tests(base_dir):
|
|||
if file.endswith(".py") and "router" in file.lower():
|
||||
print("file: ", file)
|
||||
file_path = os.path.join(root, file)
|
||||
with open(file_path, "r") as f:
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
try:
|
||||
tree = ast.parse(f.read())
|
||||
except SyntaxError:
|
||||
|
|
|
|||
|
|
@ -2169,3 +2169,32 @@ def test_resolve_model_name_from_model_id():
|
|||
|
||||
result = router.resolve_model_name_from_model_id("gpt-3.5-turbo")
|
||||
assert result == "gpt-3.5-turbo"
|
||||
|
||||
|
||||
def test_get_valid_args():
|
||||
"""Test get_valid_args static method returns valid Router.__init__ arguments"""
|
||||
# Call the static method
|
||||
valid_args = Router.get_valid_args()
|
||||
|
||||
# Verify it returns a list
|
||||
assert isinstance(valid_args, list)
|
||||
assert len(valid_args) > 0
|
||||
|
||||
# Verify it contains expected Router.__init__ arguments
|
||||
expected_args = [
|
||||
"model_list",
|
||||
"routing_strategy",
|
||||
"cache_responses",
|
||||
"num_retries",
|
||||
"timeout",
|
||||
"fallbacks",
|
||||
]
|
||||
for arg in expected_args:
|
||||
assert arg in valid_args, f"Expected argument '{arg}' not found in valid_args"
|
||||
|
||||
# Verify "self" is not in the list (since it's removed)
|
||||
assert "self" not in valid_args
|
||||
|
||||
# Verify it contains keyword-only arguments too
|
||||
# These are common Router.__init__ parameters
|
||||
assert "assistants_config" in valid_args or "search_tools" in valid_args
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue