Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/code_coverage_tests/router_code_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down
29 changes: 29 additions & 0 deletions tests/router_unit_tests/test_router_helper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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