Spaces:
Sleeping

File size: 1,186 Bytes
519acb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""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()