Files
OpenBB/tests/test_fa/test_fa_yield_curve_model.py
colin99d 4d2239d386 Refactored Tests (#640)
* Added basic openpyxl

* Add screener checks to confirm that preset is correct (#580)

* refactor screener finviz_view to view and model

* Add checks for defined screener preset

* Feature/fraud indicators (#581)

* Fixed glitch reading AlphaVantage API key

* Bug fix

* Added mscore metric

* Refactored code, added error handling

* Updated reademe.md

* Figuring out pre-commit

* Figuring out pre-commit

* Improved formating and code

* Added Zscore

* Formatted code

Co-authored-by: Colin Delahunty <colindelahunty@Colins-Air.attlocal.net>

* Reformated tests and started writing FA

* Removed excel analytics

* Figured out testing with input and print

* Figured out testing with input and print

* Added av_view tests

* Added av_view tests

* Added main_helper tests

* Fixed Poetry

* Added main helper tests

* Expanded pycoingecko_view

* Fixed ETF model

* Added coinpaprika view tests

* Added optimizer view tests

* Updated tests

Co-authored-by: Colin Delahunty <colindelahunty@Colins-Air.attlocal.net>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: Colin Delahunty <colindelahunty@Colins-MacBook-Air.local>
2021-08-07 00:34:25 +01:00

73 lines
2.0 KiB
Python

""" fundamental_analysis/yield_curve_model.py tests """
from datetime import datetime
from io import StringIO
import unittest
from unittest import mock
import pandas as pd
# pylint: disable=unused-import
from gamestonk_terminal.test_helper import ( # noqa: F401
parameterize_from_file,
pytest_generate_tests,
)
from gamestonk_terminal.stocks.fundamental_analysis.yield_curve_model import (
get_yield_curve,
get_yield_curve_year,
)
assertions = unittest.TestCase("__init__")
class TestFaYieldCurveModel:
@mock.patch(
"gamestonk_terminal.stocks.fundamental_analysis.yield_curve_model.get_yield_curve_year"
)
@parameterize_from_file(
"test_get_yield_curve",
"../tests/data/fa_yield_curve_model.yaml",
)
# pylint: disable=too-many-arguments
def test_get_yield_curve(
self,
mock_get_yield_curve_year,
start,
end,
mock_get_yield_curve_year_rets,
expected_result,
):
rets = list()
for a_ret in mock_get_yield_curve_year_rets:
rets.append(
pd.read_csv(StringIO(a_ret), header=0, index_col=0, parse_dates=True)
)
mock_get_yield_curve_year.side_effect = rets
df = get_yield_curve(
datetime.strptime(start, "%m/%d/%y"),
datetime.strptime(end, "%m/%d/%y"),
)
assertions.assertEqual(
df.to_csv().replace("\r\n", "\n"), expected_result.replace("\r\n", "\n")
)
@mock.patch(
"gamestonk_terminal.stocks.fundamental_analysis.yield_curve_model.requests"
)
@parameterize_from_file(
"test_get_yield_curve_year",
"../tests/data/fa_yield_curve_model.yaml",
)
def test_get_yield_curve_year(
self, mock_request_get, year, mock_yield_curve_page, expected_result
):
mock_request_get.get().text = mock_yield_curve_page
ret = get_yield_curve_year(year)
assertions.assertEqual(
ret.to_csv().replace("\r\n", "\n"), expected_result.replace("\r\n", "\n")
)