Files
OpenBB/tests/openbb_terminal/economy/test_nasdaq_model.py
James Maslek 70d35ff598 Economic calendar (#2936)
* First push

* Second commit

* Comment out 'spread'

* list to List
2022-10-21 15:36:31 +02:00

60 lines
1.5 KiB
Python

# IMPORTATION THIRDPARTY
import pandas as pd
import pytest
# IMPORTATION INTERNAL
from openbb_terminal.economy import nasdaq_model
@pytest.fixture(scope="module")
def vcr_config():
return {
"filter_query_parameters": [("api_key", "MOCK_API_KEY")],
}
@pytest.mark.vcr(record_mode="none")
def test_check_country_code_type(recorder):
list_of_codes = "VNM,ARG,AUS"
result_list = nasdaq_model.check_country_code_type(list_of_codes=list_of_codes)
recorder.capture(result_list)
@pytest.mark.vcr
def test_get_big_mac_index(recorder):
result_df = nasdaq_model.get_big_mac_index(country_code="VNM")
recorder.capture(result_df)
@pytest.mark.vcr(record_mode="none")
def test_get_big_mac_index_no_response(mocker):
# MOCK GET
attrs = {"status_code": 400}
mock_response = mocker.Mock(**attrs)
mocker.patch(target="requests.get", new=mocker.Mock(return_value=mock_response))
result_df = nasdaq_model.get_big_mac_index(country_code="VNM")
assert isinstance(result_df, pd.DataFrame)
assert result_df.empty
@pytest.mark.vcr
def test_get_economic_calendar(recorder):
result_df = nasdaq_model.get_economic_calendar(
["United States"], start_date="2022-10-20", end_date="2022-10-21"
)
recorder.capture(result_df)
@pytest.mark.vcr
def test_get_economic_calendar_bad_country_name(recorder):
result_df = nasdaq_model.get_economic_calendar(
"hidhf", start_date="2022-10-20", end_date="2022-10-21"
)
recorder.capture(result_df)