Skip to content

Commit

Permalink
Merge pull request OpenBB-finance#311 from DidierRLopes/add-fred-test
Browse files Browse the repository at this point in the history
Adding Fred unit test
  • Loading branch information
aia authored Apr 3, 2021
2 parents f162ced + cf029cf commit df5228c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_fred_fred_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
""" fred/fred_view.py tests """
import unittest
from unittest import mock
from io import StringIO
import pandas as pd

# pylint: disable=unused-import
from gamestonk_terminal.fred.fred_view import get_fred_data # noqa: F401

fred_data_mock = """
,GDP
2019-01-01,21115.309
2019-04-01,21329.877
2019-07-01,21540.325
2019-10-01,21747.394
2020-01-01,21561.139
2020-04-01,19520.114
2020-07-01,21170.252
2020-10-01,21494.731
"""


class TestFredFredView(unittest.TestCase):
@mock.patch("gamestonk_terminal.fred.fred_view.Fred.get_series")
def test_get_fred_data(self, mock_get_series):
fred_data = pd.read_csv(StringIO(fred_data_mock), header=0, index_col=0)

mock_get_series.return_value = fred_data

get_fred_data(["--noplot"], "gdp")

0 comments on commit df5228c

Please sign in to comment.