Files
OpenBB/tests/openbb_terminal/econometrics/test_econometrics_controller.py
Theodore Aptekarev 775d218891 Add parser for input command arguments (The Forward Slash PR) (#2064)
* Add helper command to filter unix paths and other edge cases

* Remove sort argument filtering from parsing

* Make --file arg mandatory for loading files

* Refactor queue parsing logic

* Enable adding controller level input parsing filters

* Remove the github repo path hack because it's not needed anymore

* Fix typos and line length linting

* Update unix path parser to match known extensions

* Update oss custom filters to not require space after slash arg

* Fix tests and failing linters

* Add pre-commit hook to check for reserved arguments validity

* Fix tests

* Fix finviz compare screener tests

* Fix screener test

* Fix screener test

* Fix float representation in pd dataframe on finviz screener tests

* Update test records

* Update test records

* Remove explicit float formatting in tests

* Update tests

* Remove prepending file argument

* Update long arguments that have lost their short default to file

* Update arguments in docs

* Update portfolio test data

* Fix econometrics/desc throwing error on empty df and fix tests

* Update tests

* Fix econometrics load autocompletion

* Fix portfolio tests giving different results every time

* Allow loading openbb scripts from arbitrary path

* Fix passing path as a terminal argument

* Fix guess game being case sensitive

* Silence bandit warning about using pseudo-random generators

* Update gov tests

* Fix screener sort fields that have forward slash

* Make controllers apply custom argument filters on entry

Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
2022-08-05 12:51:23 +03:00

197 lines
5.5 KiB
Python

import pytest
import pandas as pd
from openbb_terminal.econometrics.econometrics_controller import EconometricsController
# pylint: disable=W0621
@pytest.fixture()
def controller(mocker):
if mocker:
mocker.patch(
"openbb_terminal.econometrics.econometrics_controller.obbff.USE_PROMPT_TOOLKIT",
True,
)
mocker.patch(
"openbb_terminal.econometrics.econometrics_controller.session", True
)
return EconometricsController()
def test_update_runtime_choices(controller):
controller.update_runtime_choices()
assert controller.choices
@pytest.mark.parametrize(
"other",
[
["-f", "badpath.xlsx"],
["-f", "badpath.xlsx", "alias"],
["badpath.xlsx"],
["-f", "cancer", "-a", "dataset"],
[],
["-ex"],
],
)
def test_call_load(controller, other):
controller.call_load(other)
@pytest.mark.parametrize("other", [["dataset"], ["-n", "data"]])
def test_call_export(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_export(other)
@pytest.mark.skip
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_remove(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_remove(other)
@pytest.mark.skip
@pytest.mark.parametrize("other", [["data"], ["-n", "data"], []])
def test_call_options(controller, other):
controller.call_options(other)
@pytest.mark.parametrize("other", [["cancer-dataset"], ["-c", "data"], []])
def test_call_plot(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_plot(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"other",
[
["data"],
["-n", "dataset", "-s", "badcol"],
["-n", "dataset", "-s", "cancer"],
[],
],
)
def test_call_show(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_show(other)
controller.datasets = {"dataset": pd.DataFrame()}
controller.call_show(["dataset"])
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_desc(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_desc(other)
controller.datasets = {"dataset": pd.DataFrame()}
controller.call_desc(["-n", "dataset"])
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"other",
[
["data"],
["-n", "dataset"],
[],
["cancer-dataset", "int"],
["cancer-dataset", "badbad"],
["cancer-dataset", "date"],
],
)
def test_call_type(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_type(other)
@pytest.mark.record_stdout
def test_call_index(controller):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_index(["dataset", "cancer", "-a"])
controller.call_index(["dataset", "cancer", "-a"])
controller.call_index(["dataset", "cancer", "-d"])
controller.call_index(["dataset", "cancer", "oogabooga", "-d"])
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_ols(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_ols(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"other", [["cancer-dataset"], ["cancer-datast"], ["-n", "dataset"], []]
)
def test_call_norm(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_norm(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"other", [["cancer-dataset"], ["cancer-datast"], ["-n", "dataset"], []]
)
def test_call_root(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_root(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"other",
[
["cancer-dataset"],
["-r", "cancer-dataset", "population-dataset", "-t", "pols", "-ee", "-te"],
],
)
def test_call_panel(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_panel(other)
@pytest.mark.record_stdout
def test_call_compare(controller):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_compare([])
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_dwat(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_dwat(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_bgod(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_bgod(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_bpag(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_bpag(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_granger(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_granger(other)
@pytest.mark.record_stdout
@pytest.mark.parametrize("other", [["data"], ["-n", "dataset"], []])
def test_call_coint(controller, other):
controller.call_load(["-f", "cancer", "-a", "dataset"])
controller.call_coint(other)