Files
litellm/tests/test_litellm/proxy/client/cli/test_global_options.py
T
Krish Dholakia ef42461c1e Litellm fix GitHub action testing (#11163)
* test: add __init__.py files

* refactor: rename test folder to avoid naming conflict

* test: update workflows

* test: update tests

* test: update imports

* test: update tests

* test: remove unused import

* ci(test-litellm.yml): add pytest retry to github workflow

* test: fix test
2025-05-26 14:41:42 -07:00

41 lines
1.6 KiB
Python

# stdlib imports
import os
from unittest.mock import patch
import pytest
from click.testing import CliRunner
from litellm._version import version as litellm_version
from litellm.proxy.client.cli import cli
@pytest.fixture
def cli_runner():
return CliRunner()
def test_cli_version_flag(cli_runner):
"""Test that --version prints the correct version, server URL, and server version, and exits successfully"""
with patch(
"litellm.proxy.client.health.HealthManagementClient.get_server_version",
return_value="1.2.3",
), patch.dict(os.environ, {"LITELLM_PROXY_URL": "http://localhost:4000"}):
result = cli_runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert f"LiteLLM Proxy CLI Version: {litellm_version}" in result.output
assert "LiteLLM Proxy Server URL: http://localhost:4000" in result.output
assert "LiteLLM Proxy Server Version: 1.2.3" in result.output
def test_cli_version_command(cli_runner):
"""Test that 'version' command prints the correct version, server URL, and server version, and exits successfully"""
with patch(
"litellm.proxy.client.health.HealthManagementClient.get_server_version",
return_value="1.2.3",
), patch.dict(os.environ, {"LITELLM_PROXY_URL": "http://localhost:4000"}):
result = cli_runner.invoke(cli, ["version"])
assert result.exit_code == 0
assert f"LiteLLM Proxy CLI Version: {litellm_version}" in result.output
assert "LiteLLM Proxy Server URL: http://localhost:4000" in result.output
assert "LiteLLM Proxy Server Version: 1.2.3" in result.output