Skip to content

Commit

Permalink
Merge pull request #20 from sledilnik/fix-vaccinations_by_region_by_day
Browse files Browse the repository at this point in the history
Fix field mixup in vaccinations_by_region_by_day
  • Loading branch information
stefanb authored May 16, 2021
2 parents 48e9c9c + 2c245ec commit cf3c939
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cepimose/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,22 @@ def _parse_vaccinations_by_region_by_day(data):
people_fully_vaccinated = None
for element in resp:
C = element["C"]
date = parse_date(C[0])
people_vaccinated = C[1] if len(C) >= 2 else people_vaccinated
people_fully_vaccinated = C[2] if len(C) >= 3 else people_fully_vaccinated

if len(C) == 3:
date = parse_date(C[0])
people_vaccinated = C[1]
people_fully_vaccinated = C[2]
elif len(C) == 2:
date = parse_date(C[0])
R = element["R"]
if R == 2:
people_fully_vaccinated = C[1]
else:
people_vaccinated = C[1]
elif len(C) == 1:
date = parse_date(C[0])
else:
raise Exception("Unknown item length!")

parsed_data.append(
VaccinationByDayRow(
Expand Down
10 changes: 10 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ def test_vaccinations_by_region_by_day(self):
self.assertTrue(len(element[1]) != 0)
self.assertDatesIncreaseSince(element[1], datetime.datetime(2020, 12, 27))

# values should be growing
firstPrevious = 0
secondPrevious = 0
for row in data[element[0]]:
print(row, firstPrevious, secondPrevious)
self.assertGreaterEqual(row.first_dose, firstPrevious)
self.assertGreaterEqual(row.second_dose, secondPrevious)
firstPrevious = row.first_dose
secondPrevious = row.second_dose

pomurska_region = data[cepimose.data.Region.POMURSKA]

def assertRow(row, expected_date, expected_first, expected_second):
Expand Down

0 comments on commit cf3c939

Please sign in to comment.