Files
OpenBB/tests/openbb_terminal/mutual_funds/test_mstarpy_view.py
DidierRLopes 72a46fbfbf OpenBB Script Routines major improvement (#5005)
* Allow to set variables and do loops

* Fix mypy errors

* improve code

* mypy

* pylint

* accepts Openbb date keywords like 1MONTHAGO,LASTFRIDAY,3YEARSFROMNOW,NEXTTUESDAY

* warn fix

* add documentation for script foreach and vars creation

* refactor controller as per James request

* black linting

* add another warning

* Editing some routine enhancements (#5063)

* move routine to new file

* Move to relativedelta and add some tests

* Fix mocking

* Get match_and_return_openbb_keyword_date to 100% cov

* start testing parse script

* remove rogue prints

---------

Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>

* big improvement in routines tests

* mypy lint

* ruff lint

* lint

* typo

* test relative time

* cover edge case of home at end of script

* fix edge case for going to home at start

* explain better slicing

* foreach tests added

* lint

* allow foreach loops to have different var names that is iterating

* foreach more powerful

* warning when var in foreach is not used

* fail script when varname that iterates foreach loop is never defined

* black

* lint again

* ruff

* improve another edge case

* fix test and fix a description

* fix nft test and routine test

* why mutual fund test failing

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>
2023-05-30 17:33:59 +00:00

83 lines
1.9 KiB
Python

"""Test the mstrapy view."""
import pytest
from mstarpy import Funds
from openbb_terminal.mutual_funds import mstarpy_view
EXAMPLE_FUND = Funds(
"Vanguard",
"US",
)
def test_display_carbon_metrics():
mstarpy_view.display_carbon_metrics(loaded_funds=EXAMPLE_FUND)
def test_display_exclusion_policy():
mstarpy_view.display_exclusion_policy(loaded_funds=EXAMPLE_FUND)
@pytest.mark.parametrize(
"loaded_fund, start_date, end_date, kwargs",
[
(
EXAMPLE_FUND,
"2020-01-01",
"2020-12-31",
{"comparison": "category", "external_axes": False},
),
],
)
def test_display_historical(loaded_fund, start_date, end_date, kwargs):
mstarpy_view.display_historical(
loaded_funds=loaded_fund,
start_date=start_date,
end_date=end_date,
**kwargs,
)
@pytest.mark.record_verify_screen
@pytest.mark.skip
def test_display_holdings():
mstarpy_view.display_holdings(loaded_funds=EXAMPLE_FUND)
@pytest.mark.record_verify_screen
@pytest.mark.parametrize(
"term, country",
[
("Vanguard", "united_states"),
],
)
def test_display_load(term, country):
funds = mstarpy_view.display_load(term=term, country=country)
assert isinstance(funds, EXAMPLE_FUND.__class__)
@pytest.mark.skip
@pytest.mark.record_verify_screen
@pytest.mark.parametrize(
"term, country, limit",
[
("Vanguard", "united_states", 10),
],
)
def test_display_search(term, country, limit):
mstarpy_view.display_search(term=term, country=country, limit=limit)
@pytest.mark.record_verify_screen
@pytest.mark.parametrize(
"loaded_fund, asset_type, external_axes",
[
(EXAMPLE_FUND, "all", False),
],
)
def test_display_sector(loaded_fund, asset_type, external_axes):
mstarpy_view.display_sector(
loaded_funds=loaded_fund, asset_type=asset_type, external_axes=external_axes
)