Files
OpenBB/tests/test_terminal.py
jmaslek b71abcfbf4 Updating some names (#1575)
* quick econ fix

* black

* keys and feature flags

* terminal name 👀

* some more replacements

* some more replacements

* edit pyproject

* gst -> openbb

* add example portfolios back to git

* Update api from gst

* sorry.  skipping some tests

* another round of names

* another round of test edits

* Missed some .gst refs and update timezone

* water mark stuff

* Fixing Names in terminal.spec and name of GTFF_DEFAULTS to OBBFF_DEFAULTS

* fix more GST to OpenBB Terminal

* Logging : merge conflicts with main

* Revert wrong files

Co-authored-by: Andrew <andrew.kenreich@gmail.com>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
2022-03-29 09:46:26 -04:00

60 lines
1.8 KiB
Python

from contextlib import contextmanager
import pytest
import terminal
@pytest.mark.skip
@pytest.mark.block_network
@pytest.mark.vcr(record_mode="none")
@pytest.mark.record_stdout
def test_terminal_quick_exit(mocker, monkeypatch):
monkeypatch.setattr(terminal.obbff, "ENABLE_QUICK_EXIT", True)
monkeypatch.setattr(terminal.obbff, "USE_ION", False)
monkeypatch.setattr(terminal.obbff, "USE_PROMPT_TOOLKIT", True)
mocker.patch("sys.stdin")
terminal.terminal()
@pytest.mark.skip
@pytest.mark.vcr(record_mode="none")
@pytest.mark.record_stdout
def test_terminal_quit(mocker, monkeypatch):
monkeypatch.setattr(terminal.obbff, "ENABLE_QUICK_EXIT", False)
monkeypatch.setattr(terminal.obbff, "USE_ION", False)
monkeypatch.setattr(terminal.obbff, "USE_PROMPT_TOOLKIT", True)
mocker.patch("sys.stdin")
mocker.patch("builtins.input", return_value="e")
mocker.patch("terminal.session")
mocker.patch("terminal.session.prompt", return_value="e")
mocker.patch("terminal.print_goodbye")
spy_print_goodbye = mocker.spy(terminal, "print_goodbye")
terminal.terminal()
spy_print_goodbye.assert_called_once()
@contextmanager
def no_suppress():
yield
@pytest.mark.vcr(record_mode="none")
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"debug, test, verbose, filtert, path",
[
(True, False, False, None, None),
(False, False, False, None, ["scripts/test_alt_covid.openbb"]),
(False, True, False, "alt_covid", ["scripts/"]),
(False, True, True, "alt_covid", ["scripts/"]),
],
)
def test_menu(mocker, debug, test, filtert, path, verbose):
mocker.patch(target="terminal.terminal")
mocker.patch(target="terminal.suppress_stdout", side_effect=no_suppress)
terminal.main(debug, test, filtert, path, verbose)