mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
* stash some changes * add more robust testing * mypy * point PR at V5 * introduce spec file * codespell * test fix * fix workflow environment setup * fix workflow environment setup * fix workflow environment setup * add pyyaml to dependencies * split lint jobs * fix workflow environment setup * fix workflow environment setup * workflow env setup * workflow env setup * clean up code comments * add auth hook entrypoints * codespell * add codegen feature * codespell * move _unpack into dispatchers for consistency with codegen packages * surface nested models in the response * fix missing coverage in CI * socrata updates * test fix * detect plotly output * add --include and --exclude flags from generate-extension command * cap test matrix at python 3.14 * no useless comments * platform controller command description split * merge URL overloads from path params * exclude none and unset from model dump --------- Co-authored-by: deeleeramone <> Co-authored-by: Copilot <copilot@github.com>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Test the Config Setup."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from openbb_cli.config.setup import bootstrap
|
|
|
|
|
|
def test_bootstrap_creates_directory_and_file():
|
|
"""Test that bootstrap creates the settings directory and environment file."""
|
|
with (
|
|
patch("pathlib.Path.mkdir") as mock_mkdir,
|
|
patch("pathlib.Path.touch") as mock_touch,
|
|
):
|
|
bootstrap()
|
|
mock_mkdir.assert_called_once_with(parents=True, exist_ok=True)
|
|
mock_touch.assert_called_once_with(exist_ok=True)
|
|
|
|
|
|
def test_bootstrap_directory_exists():
|
|
"""Test bootstrap when the directory already exists."""
|
|
with (
|
|
patch("pathlib.Path.mkdir") as mock_mkdir,
|
|
patch("pathlib.Path.touch") as mock_touch,
|
|
):
|
|
bootstrap()
|
|
mock_mkdir.assert_called_once_with(parents=True, exist_ok=True)
|
|
mock_touch.assert_called_once_with(exist_ok=True)
|
|
|
|
|
|
def test_bootstrap_file_exists():
|
|
"""Test bootstrap when the environment file already exists."""
|
|
with (
|
|
patch("pathlib.Path.mkdir") as mock_mkdir,
|
|
patch("pathlib.Path.touch") as mock_touch,
|
|
):
|
|
bootstrap()
|
|
mock_mkdir.assert_called_once_with(parents=True, exist_ok=True)
|
|
mock_touch.assert_called_once_with(exist_ok=True)
|
|
|
|
|
|
def test_bootstrap_permission_error():
|
|
"""Test bootstrap handles permission errors gracefully."""
|
|
with (
|
|
patch("pathlib.Path.mkdir") as mock_mkdir,
|
|
patch("pathlib.Path.touch"),
|
|
pytest.raises(PermissionError),
|
|
):
|
|
mock_mkdir.side_effect = PermissionError("No permission to create directory")
|
|
bootstrap()
|