Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/terminal tests #5919

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openbb_terminal/core/completer/choices.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down
14 changes: 12 additions & 2 deletions openbb_terminal/stocks/stocks_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
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

Expand Down Expand Up @@ -340,6 +340,15 @@ def call_quote(self, other_args: List[str]):
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]:
Expand All @@ -351,7 +360,8 @@ def call_quote(self, other_args: List[str]):
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,
Expand Down
5 changes: 3 additions & 2 deletions tests/openbb_terminal/stocks/test_stocks_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand All @@ -539,5 +539,6 @@ def mock_yf_download(*args, **kwargs):
"TSLA",
"--start=2021-12-17",
"--end=2021-12-18",
"--source=YahooFinance",
]
controller.call_load(other_args=other_args)