Skip to content

Commit 5cc361c

Browse files
authored
Merge branch 'main' into ndefries/qsf-umd-bugs
2 parents 5e90d2a + 194f23a commit 5cc361c

File tree

8 files changed

+40
-29
lines changed

8 files changed

+40
-29
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.12
2+
current_version = 0.3.13
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/workflows/publish-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@v2
2222
with:
2323
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
24+
fetch-depth: 5
2425
- name: Set up Python 3.8
2526
uses: actions/setup-python@v2
2627
with:

_delphi_utils_python/.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.3
2+
current_version = 0.3.4
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .nancodes import Nans
1616
from .weekday import Weekday
1717

18-
__version__ = "0.3.3"
18+
__version__ = "0.3.4"

_delphi_utils_python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name="delphi_utils",
29-
version="0.3.3",
29+
version="0.3.4",
3030
description="Shared Utility Functions for Indicators",
3131
long_description=long_description,
3232
long_description_content_type="text/markdown",

dsew_community_profile/delphi_dsew_community_profile/pull.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def as_cached_filename(params, config):
408408
def fetch_listing(params):
409409
"""Generate the list of report files to process."""
410410
export_start_date = params['indicator'].get(
411-
'export_start_date', datetime.datetime.fromtimestamp(0).date()
411+
'export_start_date', datetime.datetime.utcfromtimestamp(0).date()
412412
)
413413

414414
listing = requests.get(DOWNLOAD_LISTING).json()['metadata']['attachments']

dsew_community_profile/tests/test_pull.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def _set_df_dtypes(df: pd.DataFrame, dtypes: Dict[str, Any]) -> pd.DataFrame:
3939
df[k] = df[k].astype(v)
4040
return df
4141

42+
4243
class TestPull:
4344
def test_DatasetTimes(self):
4445
examples = [
@@ -158,31 +159,35 @@ def test_Dataset_parse_sheet(self):
158159
# TODO
159160
pass
160161

161-
@patch('requests.get')
162-
@patch('os.path.exists')
163-
def test_fetch_listing(self, mock_listing, mock_exists):
162+
def test_fetch_listing(self):
164163
inst = namedtuple("attachment", "assetId filename publish cache")
165164
instances = list(chain(*[
166165
[
167-
inst(f"{i}", f"2021010{i}.xlsx", date(2021, 1, i), f"{i}---2021010{i}.xlsx"),
168-
inst(f"p{i}", f"2021010{i}.pdf", date(2021, 1, i), f"p{i}---2021010{i}.pdf"),
166+
inst(f"{i}", f"2021010{i}.xlsx", date(2021, 1, i), f"2021010{i}--{i}.xlsx"),
167+
inst(f"p{i}", f"2021010{i}.pdf", date(2021, 1, i), f"2021010{i}--p{i}.pdf"),
169168
]
170169
for i in [1, 2, 3, 4, 5]
171170
]))
172171

173-
mock_listing.return_value = Mock()
174-
mock_listing.return_value.json = Mock(
175-
return_value = {
176-
'metadata': {
177-
'attachments': [
178-
{"assetId": i.assetId, "filename": i.filename}
179-
for i in instances
180-
]
181-
}
182-
}
183-
)
184-
185-
mock_exists.reset_mock(return_value=False)
172+
# Solution from https://stackoverflow.com/questions/15753390/
173+
#how-can-i-mock-requests-and-the-response
174+
def mocked_requests_get(*args, **kwargs):
175+
class MockResponse:
176+
def __init__(self, json_data):
177+
self.json_data = json_data
178+
179+
def json(self):
180+
return self.json_data
181+
182+
return MockResponse({
183+
'metadata': {
184+
'attachments': [
185+
{"assetId": i.assetId, "filename": i.filename}
186+
for i in instances
187+
]
188+
}
189+
}
190+
)
186191

187192
def as_listing(instance):
188193
return {
@@ -192,15 +197,20 @@ def as_listing(instance):
192197
"publish_date": instance.publish
193198
}
194199
ex = example(
195-
{'indicator':{'reports':'new'}},
200+
{'indicator':{'reports':'new', 'input_cache':''}},
196201
[
197202
as_listing(instance)
198203
for i, instance in filter(lambda x: x[0]%2 == 0, enumerate(instances))
199204
]
200205
)
201206

202-
for actual, expected in zip(fetch_listing(ex.given), ex.expected):
203-
assert actual == expected
207+
with patch('requests.get', side_effect=mocked_requests_get):
208+
with patch('os.path.exists', return_value=False):
209+
for actual, expected in zip(fetch_listing(ex.given), ex.expected):
210+
assert actual == expected
211+
212+
with patch('os.path.exists', return_value=True):
213+
assert fetch_listing(ex.given) == []
204214

205215
def test_nation_from_state(self):
206216
geomapper = GeoMapper()

facebook/qsf-tools/generate-changelog.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ get_codebook <- function(path_to_codebook) {
7575

7676
return(codebook)
7777
}
78-
78+
7979
# Try to load `path_to_diff`. Check if it is a single CSV or a directory
8080
# containing a set of CSVs.
8181
get_diff <- function(path_to_diff) {
@@ -196,7 +196,7 @@ prepare_matrix_base_questions_for_join <- function(qsf_diff, codebook) {
196196
qsf_diff %>% distinct(variable_name) %>% pull(),
197197
codebook %>% distinct(variable) %>% pull()
198198
)
199-
199+
200200
# Add an underscore to the unmatched variable names to create a regex pattern
201201
matrix_prefixes <- paste0(vars_not_in_codebook, "_")
202202
names(matrix_prefixes) <- vars_not_in_codebook
@@ -292,7 +292,7 @@ prepare_matrix_base_questions_for_join <- function(qsf_diff, codebook) {
292292
join_variable_old_wave = coalesce(join_variable_old_wave, variable_name)
293293
) %>%
294294
select(-join_variable)
295-
295+
296296
return(list("diff" = qsf_diff, "vars_not_in_codebook" = vars_not_in_codebook))
297297
}
298298

0 commit comments

Comments
 (0)