Skip to content

Commit

Permalink
Merge pull request #8 from jalezi/fix-by-manufacturer-double-dates
Browse files Browse the repository at this point in the history
fix(parser)(supplied_by_manufacturer): same date
  • Loading branch information
stefanb authored Apr 10, 2021
2 parents 67d470c + 6d4a500 commit 6a20074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 9 additions & 7 deletions cepimose/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def get_manufacturer(num):
value = C[1]
obj = create_obj(date)
obj[manufacturer] = value
setattr(parsed_data[-1], manufacturer, value)

if R == 2:
# same manufacturer as previous
Expand All @@ -181,14 +182,15 @@ def get_manufacturer(num):
obj = create_obj(date)
obj[manufacturer] = value

parsed_data.append(
VaccinationByManufacturerRow(
date=obj["date"],
pfizer=obj["pfizer"],
moderna=obj["moderna"],
az=obj["az"],
if R != 1:
parsed_data.append(
VaccinationByManufacturerRow(
date=obj["date"],
pfizer=obj["pfizer"],
moderna=obj["moderna"],
az=obj["az"],
)
)
)
return parsed_data


Expand Down
7 changes: 3 additions & 4 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ def assertRow(row, expected_date, expected):
assertRow(data[1], datetime.datetime(2020, 12, 30), [8190, None, None]) # R = 2
assertRow(data[3], datetime.datetime(2021, 1, 11), [19890, None, None]) # R = 6
assertRow(
data[16], datetime.datetime(2021, 2, 25), [None, None, 16800]
) # R = None
assertRow(data[17], datetime.datetime(2021, 2, 25), [None, 8400, None]) # R = 1
data[16], datetime.datetime(2021, 2, 25), [None, 8400, 16800]
) # combined: two response data items with same date; second has R = 1

# self.assertDatesIncreaseSince(data, datetime.datetime(2020, 12, 26))
self.assertDatesIncreaseSince(data, datetime.datetime(2020, 12, 26))

def test_supplied_by_manufacturer_cumulative(self):
data = cepimose.vaccines_supplied_by_manufacturer_cumulative()
Expand Down

0 comments on commit 6a20074

Please sign in to comment.