""" econ/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.econ.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.econ.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")

[((24, 5, 24, 68), 'unittest.mock.patch', 'mock.patch', ({(24, 16, 24, 67): '"""gamestonk_terminal.econ.fred_view.Fred.get_series"""'}, {}), "('gamestonk_terminal.econ.fred_view.Fred.get_series')", False, 'from unittest import mock\n'), ((30, 8, 30, 42), 'gamestonk_terminal.econ.fred_view.get_fred_data', 'get_fred_data', ({(30, 22, 30, 34): "['--noplot']", (30, 36, 30, 41): '"""gdp"""'}, {}), "(['--noplot'], 'gdp')", False, 'from gamestonk_terminal.econ.fred_view import get_fred_data\n'), ((26, 32, 26, 56), 'io.StringIO', 'StringIO', ({(26, 41, 26, 55): 'fred_data_mock'}, {}), '(fred_data_mock)', False, 'from io import StringIO\n')]