Files
OpenBB/cli/tests/test_cli.py
Igor Radovanovic a116d9bbf2 [Feature] - OpenBB Platform CLI Unit tests (#6397)
* Unit test batch 1

* CLI controller

* Test batch 3

* Test batch 4

* Test batch 5

* clean some workflows and setup actions

* test

* rename wfs

* rename

* update action

* Skip

* fix cli tests

---------

Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
2024-05-14 15:38:06 +00:00

46 lines
1.4 KiB
Python

"""Test the CLI module."""
from unittest.mock import patch
from openbb_cli.cli import main
@patch("openbb_cli.cli.bootstrap")
@patch("openbb_cli.cli.launch")
@patch("sys.argv", ["openbb", "--dev", "--debug"])
def test_main_with_dev_and_debug(mock_launch, mock_bootstrap):
"""Test the main function with dev and debug flags."""
main()
mock_bootstrap.assert_called_once()
mock_launch.assert_called_once_with(True, True)
@patch("openbb_cli.cli.bootstrap")
@patch("openbb_cli.cli.launch")
@patch("sys.argv", ["openbb"])
def test_main_without_arguments(mock_launch, mock_bootstrap):
"""Test the main function without arguments."""
main()
mock_bootstrap.assert_called_once()
mock_launch.assert_called_once_with(False, False)
@patch("openbb_cli.cli.bootstrap")
@patch("openbb_cli.cli.launch")
@patch("sys.argv", ["openbb", "--dev"])
def test_main_with_dev_only(mock_launch, mock_bootstrap):
"""Test the main function with dev flag only."""
main()
mock_bootstrap.assert_called_once()
mock_launch.assert_called_once_with(True, False)
@patch("openbb_cli.cli.bootstrap")
@patch("openbb_cli.cli.launch")
@patch("sys.argv", ["openbb", "--debug"])
def test_main_with_debug_only(mock_launch, mock_bootstrap):
"""Test the main function with debug flag only."""
main()
mock_bootstrap.assert_called_once()
mock_launch.assert_called_once_with(False, True)