Spaces:
Sleeping

jellyscope / tests /test_cli.py
AndreLuckmann's picture
ponytail audit
50748d6
Raw History Blame Contribute Delete
1.19 kB
"""Tests for CLI entry point."""
from unittest.mock import patch
from jellyscope.cli import main
def test_main_default_args():
with (
patch("sys.argv", ["jellyscope", "--data-dir", "data"]),
patch("jellyscope.cli.create_app") as mock_create_app,
patch("jellyscope.cli.uvicorn") as mock_uvicorn,
):
main()
mock_create_app.assert_called_once()
config = mock_create_app.call_args[0][0]
assert config.host == "127.0.0.1"
assert config.port == 5000
mock_uvicorn.run.assert_called_once()
def test_main_custom_args():
with (
patch(
"sys.argv",
[
"jellyscope",
"--host",
"0.0.0.0",
"--port",
"8080",
"--data-dir",
"data",
],
),
patch("jellyscope.cli.create_app") as mock_create_app,
patch("jellyscope.cli.uvicorn") as mock_uvicorn,
):
main()
config = mock_create_app.call_args[0][0]
assert config.host == "0.0.0.0"
assert config.port == 8080
mock_uvicorn.run.assert_called_once()