Skip to content

Commit

Permalink
Add tests for db
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitor Magán committed Jan 5, 2021
1 parent cae516f commit 1d30299
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/unit/helpers/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def test_when_get_all_stats_group_by_day_then_three_value_returned(self):
call(Measurement.PCRS_LAST_24H, date),
call(Measurement.ADMITTED_PEOPLE, date),
call(Measurement.ICU_PEOPLE, date),
call(Measurement.ACCUMULATED_INCIDENCE, date)])
call(Measurement.ACCUMULATED_INCIDENCE, date),
call(Measurement.PERCENTAGE_ADMITTED, date),
call(Measurement.PERCENTAGE_ICU, date),
call(Measurement.VACCINATIONS, date)])

def test_when_get_all_stats_group_by_week_then_three_value_returned(self):
influx = Influx()
Expand All @@ -123,23 +126,29 @@ def test_when_get_all_stats_group_by_week_then_three_value_returned(self):
call(Measurement.DEATHS, date),
call(Measurement.PCRS_LAST_24H, date),
call(Measurement.ADMITTED_PEOPLE, date),
call(Measurement.ICU_PEOPLE, date)])
call(Measurement.ICU_PEOPLE, date),
call(Measurement.VACCINATIONS, date)])
influx.get_stat_group_by_day.assert_has_calls([call(Measurement.ACCUMULATED_INCIDENCE, datetime(2020, 10, 9)),
call(Measurement.PERCENTAGE_ADMITTED, datetime(2020, 10, 9)),
call(Measurement.PERCENTAGE_ICU, datetime(2020, 10, 9))])

def test_when_get_all_stats_accumulated_until_day_then_two_value_returned(self):
influx = Influx()
influx._pack_elements = MagicMock()
influx.get_stat_accumulated_until_day = MagicMock()
pcrs = MagicMock()
deaths = MagicMock()
vaccinations = MagicMock()
influx.get_stat_accumulated_until_day = MagicMock(side_effect=[pcrs, deaths, vaccinations])
date = MagicMock()

result = influx.get_all_stats_accumulated_until_day(date)

self.assertEqual(influx._pack_elements.return_value, result)

influx.get_stat_accumulated_until_day.assert_has_calls([call(Measurement.PCRS, date),
call(Measurement.DEATHS, date)])
call(Measurement.DEATHS, date),
call(Measurement.VACCINATIONS, date)])
influx._pack_elements.assert_called_once_with(pcrs=pcrs, deaths=deaths, vaccinations=vaccinations)

def test_given_no_args_when_pack_elements_then_empty_dict_returned(self):

Expand Down

0 comments on commit 1d30299

Please sign in to comment.