Skip to content

Commit

Permalink
fixing for test
Browse files Browse the repository at this point in the history
  • Loading branch information
aysim319 committed Jul 30, 2024
1 parent a5628ac commit 1ff5866
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions _delphi_utils_python/delphi_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
from .signal import add_prefix
from .nancodes import Nans
from .weekday import Weekday
from .covidcast_wrapper import metadata, signal

__version__ = "0.3.24"
6 changes: 3 additions & 3 deletions _delphi_utils_python/delphi_utils/validator/datafetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas as pd
import numpy as np

from ..covidcast_wrapper import metadata, signal
from delphi_utils import covidcast_wrapper
from .errors import APIDataFetchError, ValidationFailure

FILENAME_REGEX = re.compile(
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_geo_signal_combos(data_source, api_key):
source_signal_mappings = {i['source']:i['db_source'] for i in
meta_response.json()}

meta = metadata()
meta = covidcast_wrapper.metadata()

source_meta = meta[meta['data_source'] == data_source]
# Need to convert np.records to tuples so they are hashable and can be used in sets and dicts.
Expand Down Expand Up @@ -162,7 +162,7 @@ def fetch_api_reference(data_source, start_date, end_date, geo_type, signal_type
Formatting is changed to match that of source data CSVs.
"""
with warnings.catch_warnings():
api_df = signal(data_source, signal_type, start_date, end_date, geo_type)
api_df = covidcast_wrapper.signal(data_source, signal_type, start_date, end_date, geo_type)


error_context = f"when fetching reference data from {start_date} to {end_date} " +\
Expand Down
7 changes: 1 addition & 6 deletions _delphi_utils_python/tests/test_covidcast_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
from delphi_utils import covidcast_wrapper
import covidcast
from freezegun import freeze_time
import os
from pandas.testing import assert_frame_equal

TEST_DIR = Path(__file__).parent
API_KEY = os.environ.get('DELPHI_API_KEY')
covidcast.use_api_key(API_KEY)
class TestCovidcastWrapper:
API_KEY = os.environ.get('DELPHI_API_KEY')
covidcast.use_api_key(API_KEY)
def test_metadata(self):
expected_df = pd.read_pickle(f"{TEST_DIR}/test_data/covidcast_metadata.pkl")
expected_df = covidcast.metadata()
df = covidcast_wrapper.metadata()
assert_frame_equal(expected_df, df)

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions _delphi_utils_python/tests/validator/test_datafetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_bad_api_key(self, **kwargs):
get_geo_signal_combos("chng", api_key="")

@mock.patch('requests.get', side_effect=mocked_requests_get)
@mock.patch("covidcast.metadata")
@mock.patch("delphi_utils.covidcast_wrapper.metadata")
def test_get_geo_signal_combos(self, mock_metadata, mock_get):
"""Test that the geo signal combos are correctly pulled from the covidcast metadata."""
# Need to use actual data_source and signal names since we reference the API
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_get_geo_signal_combos(self, mock_metadata, mock_get):
("msa", "pcr_specimen_positivity_rate"),
("msa", "pcr_specimen_total_tests")])

@mock.patch("covidcast.signal")
@mock.patch("delphi_utils.covidcast_wrapper.signal")
def test_threaded_api_calls(self, mock_signal):
"""Test that calls to the covidcast API are made."""

Expand Down

0 comments on commit 1ff5866

Please sign in to comment.