Skip to content

Commit

Permalink
add test for fetch_data attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lpicci96 committed Jun 6, 2024
1 parent db8c7db commit e324eec
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_weo/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ def test_fetch_data(mock_fetch):
mock_fetch.assert_called_with(reader.gen_latest_version())


@patch("imf_reader.weo.reader.gen_latest_version")
@patch("imf_reader.weo.reader._fetch")
def test_fetch_data_attribute(mock_fetch, mock_gen_latest_version):
"""Test for fetch_data method attribute."""

mock_data = pd.DataFrame({"column1": [1, 2, 3], "column2": [4, 5, 6]})
mock_fetch.return_value = mock_data
mock_gen_latest_version.return_value = ("April", 2024)

# when a version is passed, check that the attribute is set
reader.fetch_data(("April", 2022))
assert reader.fetch_data.last_version_fetched == ("April", 2022)

# when no version is passed, check that the attribute is set
reader.fetch_data()
assert reader.fetch_data.last_version_fetched == ("April", 2024)



@patch("imf_reader.weo.reader._fetch.cache_clear")
def test_clear_cache(mock_cache_clear):
"""Test for clear_cache method."""
Expand Down

0 comments on commit e324eec

Please sign in to comment.