From ec945f7a2bc874cd6a8fcd6c9f91c6aa1d4333eb Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Fri, 24 Mar 2023 00:23:00 +0100 Subject: [PATCH 1/2] fix mocking --- ...d_fund0-2020-01-01-2020-12-31-kwargs0].json | 1 - .../mutual_funds/test_mstrapy_model.py | 5 ++++- .../mutual_funds/test_mstrapy_view.py | 17 ++++++++--------- .../test_mutual_fund_controller.py | 18 ++++++++++++------ 4 files changed, 24 insertions(+), 17 deletions(-) delete mode 100644 tests/openbb_terminal/mutual_funds/record/screen/test_mstrapy_view/test_display_historical[loaded_fund0-2020-01-01-2020-12-31-kwargs0].json diff --git a/tests/openbb_terminal/mutual_funds/record/screen/test_mstrapy_view/test_display_historical[loaded_fund0-2020-01-01-2020-12-31-kwargs0].json b/tests/openbb_terminal/mutual_funds/record/screen/test_mstrapy_view/test_display_historical[loaded_fund0-2020-01-01-2020-12-31-kwargs0].json deleted file mode 100644 index fbd02c2eb225..000000000000 --- a/tests/openbb_terminal/mutual_funds/record/screen/test_mstrapy_view/test_display_historical[loaded_fund0-2020-01-01-2020-12-31-kwargs0].json +++ /dev/null @@ -1 +0,0 @@ -{"out": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "err": ""} \ No newline at end of file diff --git a/tests/openbb_terminal/mutual_funds/test_mstrapy_model.py b/tests/openbb_terminal/mutual_funds/test_mstrapy_model.py index b153be5d454c..c10d9be2ddae 100644 --- a/tests/openbb_terminal/mutual_funds/test_mstrapy_model.py +++ b/tests/openbb_terminal/mutual_funds/test_mstrapy_model.py @@ -6,7 +6,10 @@ from openbb_terminal.mutual_funds import mstarpy_model -EXAMPLE_FUND = mstarpy_model.load_funds(term="Vanguard", country="US") +EXAMPLE_FUND = Funds( + "Vanguard", + "US", +) @pytest.mark.record_http() diff --git a/tests/openbb_terminal/mutual_funds/test_mstrapy_view.py b/tests/openbb_terminal/mutual_funds/test_mstrapy_view.py index b401d56e9c4a..0924d803285d 100644 --- a/tests/openbb_terminal/mutual_funds/test_mstrapy_view.py +++ b/tests/openbb_terminal/mutual_funds/test_mstrapy_view.py @@ -1,10 +1,14 @@ """Test the mstrapy view.""" import pytest +from mstarpy import Funds -from openbb_terminal.mutual_funds import mstarpy_model, mstarpy_view +from openbb_terminal.mutual_funds import mstarpy_view -EXAMPLE_FUND = mstarpy_model.load_funds(term="Vanguard", country="US") +EXAMPLE_FUND = Funds( + "Vanguard", + "US", +) def test_display_carbon_metrics(): @@ -15,7 +19,6 @@ def test_display_exclusion_policy(): mstarpy_view.display_exclusion_policy(loaded_funds=EXAMPLE_FUND) -@pytest.mark.record_verify_screen @pytest.mark.parametrize( "loaded_fund, start_date, end_date, kwargs", [ @@ -28,14 +31,12 @@ def test_display_exclusion_policy(): ], ) def test_display_historical(loaded_fund, start_date, end_date, kwargs): - chart = mstarpy_view.display_historical( + mstarpy_view.display_historical( loaded_funds=loaded_fund, start_date=start_date, end_date=end_date, **kwargs, ) - assert chart is not None - assert hasattr(chart, "save") @pytest.mark.record_verify_screen @@ -74,8 +75,6 @@ def test_display_search(term, country, limit): ], ) def test_display_sector(loaded_fund, asset_type, external_axes): - chart = mstarpy_view.display_sector( + mstarpy_view.display_sector( loaded_funds=loaded_fund, asset_type=asset_type, external_axes=external_axes ) - assert chart is not None - assert hasattr(chart, "to_html") diff --git a/tests/openbb_terminal/mutual_funds/test_mutual_fund_controller.py b/tests/openbb_terminal/mutual_funds/test_mutual_fund_controller.py index 59fdfa41c64e..b133ab602dfb 100644 --- a/tests/openbb_terminal/mutual_funds/test_mutual_fund_controller.py +++ b/tests/openbb_terminal/mutual_funds/test_mutual_fund_controller.py @@ -217,7 +217,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_load(["--fund", "UNH"]) + getattr(controller, "call_load")(["--fund", "UNH"]) + assert controller.queue == [] @@ -252,7 +253,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_country([]) + getattr(controller, "call_country")([]) + assert controller.queue == [] @@ -284,7 +286,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_plot([]) + getattr(controller, "call_plot")([]) + assert controller.queue == [] @@ -320,7 +323,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_sector([]) + getattr(controller, "call_sector")([]) + assert controller.queue == [] @@ -355,7 +359,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_holdings([]) + getattr(controller, "call_holdings")([]) + assert controller.queue == [] @@ -390,7 +395,8 @@ def __call__(self, *args, **kwargs): ) controller = mutual_fund_controller.FundController(queue=None) - controller.call_carbon([]) + getattr(controller, "call_carbon")([]) + assert controller.queue == [] From 013321a6fc126f2443fa81e8766105c87880dd6d Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Fri, 24 Mar 2023 00:50:52 +0100 Subject: [PATCH 2/2] run tests? --- openbb_terminal/alternative/alt_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_terminal/alternative/alt_controller.py b/openbb_terminal/alternative/alt_controller.py index 91954eb858ec..cc4e7e1713d9 100644 --- a/openbb_terminal/alternative/alt_controller.py +++ b/openbb_terminal/alternative/alt_controller.py @@ -54,14 +54,14 @@ def call_covid(self, _): @log_start_end(log=logger) def call_oss(self, _): - """Process oss command""" + """Process oss command.""" from openbb_terminal.alternative.oss.oss_controller import OSSController self.queue = self.load_class(OSSController, self.queue) @log_start_end(log=logger) def call_hn(self, other_args: List[str]): - """Process hn command""" + """Process hn command.""" parser = argparse.ArgumentParser( add_help=False,