mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 04:13:06 +00:00
Hotfix/terminal tests (#5919)
* skip supressed arguments * silent way of customly load on quote * specify source for call_load
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from argparse import ArgumentParser
|
||||
from argparse import SUPPRESS, ArgumentParser
|
||||
from contextlib import contextmanager
|
||||
from inspect import isfunction, unwrap
|
||||
from types import MethodType
|
||||
@@ -275,6 +275,8 @@ def _get_argument_parser(
|
||||
def _build_command_choice_map(argument_parser: ArgumentParser) -> dict:
|
||||
choice_map: dict = {}
|
||||
for action in argument_parser._actions: # pylint: disable=protected-access
|
||||
if action.help == SUPPRESS:
|
||||
continue
|
||||
if len(action.option_strings) == 1:
|
||||
long_name = action.option_strings[0]
|
||||
short_name = ""
|
||||
|
||||
@@ -27,7 +27,7 @@ from openbb_terminal.helper_funcs import (
|
||||
)
|
||||
from openbb_terminal.menu import session
|
||||
from openbb_terminal.parent_classes import StockBaseController
|
||||
from openbb_terminal.rich_config import MenuText, console
|
||||
from openbb_terminal.rich_config import MenuText, console, get_ordered_list_sources
|
||||
from openbb_terminal.stocks import cboe_view, stocks_helper, stocks_view
|
||||
from openbb_terminal.terminal_helper import suppress_stdout
|
||||
|
||||
@@ -340,6 +340,15 @@ class StocksController(StockBaseController):
|
||||
default=self.ticker,
|
||||
help="Get a quote for a specific ticker, or comma-separated list of tickers.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--load_source",
|
||||
action="store",
|
||||
dest="load_source",
|
||||
required=False,
|
||||
default=None,
|
||||
choices=get_ordered_list_sources(f"{self.PATH}load"),
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
# For the case where a user uses: 'quote BB'
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
@@ -351,7 +360,8 @@ class StocksController(StockBaseController):
|
||||
tickers = ns_parser.s_ticker.split(",")
|
||||
if ns_parser.s_ticker and len(tickers) == 1:
|
||||
self.ticker = ns_parser.s_ticker
|
||||
self.custom_load_wrapper([self.ticker])
|
||||
load_other_args = [self.ticker, "--source", ns_parser.load_source]
|
||||
self.custom_load_wrapper(load_other_args)
|
||||
|
||||
stocks_view.display_quote(
|
||||
tickers,
|
||||
|
||||
@@ -277,7 +277,7 @@ def test_call_func_expect_queue(expected_queue, func, queue):
|
||||
),
|
||||
(
|
||||
"call_quote",
|
||||
[],
|
||||
["--ticker=AAPL", "--load_source=YahooFinance"],
|
||||
"stocks_view.display_quote",
|
||||
[],
|
||||
dict(),
|
||||
@@ -523,7 +523,7 @@ def test_custom_reset(expected, ticker):
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.vcr(record_mode="none")
|
||||
def test_call_load(mocker):
|
||||
# FORCE SINGLE THREADING
|
||||
yf_download = stocks_controller.stocks_helper.yf.download
|
||||
@@ -539,5 +539,6 @@ def test_call_load(mocker):
|
||||
"TSLA",
|
||||
"--start=2021-12-17",
|
||||
"--end=2021-12-18",
|
||||
"--source=YahooFinance",
|
||||
]
|
||||
controller.call_load(other_args=other_args)
|
||||
|
||||
Reference in New Issue
Block a user