Skip to content

Commit 1ff5866

Browse files
committed
fixing for test
1 parent a5628ac commit 1ff5866

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

_delphi_utils_python/delphi_utils/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
from .signal import add_prefix
1515
from .nancodes import Nans
1616
from .weekday import Weekday
17+
from .covidcast_wrapper import metadata, signal
1718

1819
__version__ = "0.3.24"

_delphi_utils_python/delphi_utils/validator/datafetcher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas as pd
1111
import numpy as np
1212

13-
from ..covidcast_wrapper import metadata, signal
13+
from delphi_utils import covidcast_wrapper
1414
from .errors import APIDataFetchError, ValidationFailure
1515

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

120-
meta = metadata()
120+
meta = covidcast_wrapper.metadata()
121121

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

167167

168168
error_context = f"when fetching reference data from {start_date} to {end_date} " +\

_delphi_utils_python/tests/test_covidcast_wrapper.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
from delphi_utils import covidcast_wrapper
55
import covidcast
66
from freezegun import freeze_time
7-
import os
87
from pandas.testing import assert_frame_equal
98

109
TEST_DIR = Path(__file__).parent
11-
API_KEY = os.environ.get('DELPHI_API_KEY')
12-
covidcast.use_api_key(API_KEY)
1310
class TestCovidcastWrapper:
14-
API_KEY = os.environ.get('DELPHI_API_KEY')
15-
covidcast.use_api_key(API_KEY)
1611
def test_metadata(self):
17-
expected_df = pd.read_pickle(f"{TEST_DIR}/test_data/covidcast_metadata.pkl")
12+
expected_df = covidcast.metadata()
1813
df = covidcast_wrapper.metadata()
1914
assert_frame_equal(expected_df, df)
2015

Binary file not shown.

_delphi_utils_python/tests/validator/test_datafetcher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_bad_api_key(self, **kwargs):
5757
get_geo_signal_combos("chng", api_key="")
5858

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

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

0 commit comments

Comments
 (0)