Skip to content

Commit 6e22db8

Browse files
committed
fixing for test
1 parent a5628ac commit 6e22db8

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

_delphi_utils_python/delphi_utils/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
from __future__ import absolute_import
55

66
from .archive import ArchiveDiffer, GitArchiveDiffer, S3ArchiveDiffer
7+
from .covidcast_wrapper import metadata, signal
78
from .export import create_export_csv
8-
from .utils import read_params
9-
10-
from .slack_notifier import SlackNotifier
11-
from .logger import get_structured_logger
129
from .geomap import GeoMapper
13-
from .smooth import Smoother
14-
from .signal import add_prefix
10+
from .logger import get_structured_logger
1511
from .nancodes import Nans
12+
from .signal import add_prefix
13+
from .slack_notifier import SlackNotifier
14+
from .smooth import Smoother
15+
from .utils import read_params
1616
from .weekday import Weekday
1717

1818
__version__ = "0.3.24"

_delphi_utils_python/delphi_utils/validator/datafetcher.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import re
55
import threading
6+
import warnings
67
from os import listdir
78
from os.path import isfile, join
8-
import warnings
9-
import requests
10-
import pandas as pd
9+
1110
import numpy as np
11+
import pandas as pd
12+
import requests
13+
from delphi_utils import covidcast_wrapper
1214

13-
from ..covidcast_wrapper import metadata, signal
1415
from .errors import APIDataFetchError, ValidationFailure
1516

1617
FILENAME_REGEX = re.compile(
@@ -117,7 +118,7 @@ def get_geo_signal_combos(data_source, api_key):
117118
source_signal_mappings = {i['source']:i['db_source'] for i in
118119
meta_response.json()}
119120

120-
meta = metadata()
121+
meta = covidcast_wrapper.metadata()
121122

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

167168

168169
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)