Пример #1
0
 def test_calculate_dataset_no_province(self, mock_covid_api):
     # *valid response with no province
     mock_covid_api.side_effect = mock_covid_api_response
     death_trend = covid_trend.get_daily_death_trend("united-kingdom")
     self.assertEqual(3, len(death_trend[0]))  #list dates
     self.assertEqual(3, len(death_trend[1]))  #list deaths
     # calculation tests
     daily_deaths = death_trend[1]
     self.assertEqual(10, daily_deaths[0])
     self.assertEqual(-5, daily_deaths[1])
     self.assertEqual(20, daily_deaths[2])
Пример #2
0
 def test_get_daily_death_trend_api_httperror_exception(
         self, mcok_covid_api):
     mcok_covid_api.side_effect = HTTPError
     death_trend = covid_trend.get_daily_death_trend("united-kingdom")
     self.assertEqual(0, len(death_trend))
Пример #3
0
 def test_get_daily_death_trend_api_timeout_exception(self, mcok_covid_api):
     mcok_covid_api.side_effect = Timeout
     death_trend = covid_trend.get_daily_death_trend("united-kingdom")
     self.assertEqual(0, len(death_trend))
Пример #4
0
 def test_calculate_dataset_empty_json(self, mock_covid_api):
     # * empty response
     mock_covid_api.side_effect = mock_covid_empty_json
     death_trend = covid_trend.get_daily_death_trend("united-kingdom")
     self.assertEqual(0, len(death_trend))
Пример #5
0
 def test_calculate_dataset_all_province(self, mock_covid_api):
     # * valid response with all provinces
     mock_covid_api.side_effect = mock_covid_all_provinces
     death_trend = covid_trend.get_daily_death_trend("united-kingdom")
     self.assertEqual(0, len(death_trend))