def test_given_data_for_two_ccaa_when_global_data_then_sum_values_returned( self, calculate_global_incidence_mock): ccaa1 = "Melilla" pcrs1 = 100 deaths1 = 4 ccaa2 = "Andalucia" pcrs2 = 400 deaths2 = 7 data = { ccaa1: { Measurement.PCRS: pcrs1, Measurement.DEATHS: deaths1 }, ccaa2: { Measurement.PCRS: pcrs2, Measurement.DEATHS: deaths2 } } self.assertEqual( { Measurement.PCRS: pcrs1 + pcrs2, Measurement.DEATHS: deaths1 + deaths2 }, get_global_data(data)) calculate_global_incidence_mock.assert_not_called()
def test_given_data_for_one_ccaa_when_global_data_then_ccaa_data_returned( self, calculate_global_incidence_mock): ccaa = "Melilla" pcrs = 100 deaths = 4 data = {ccaa: {Measurement.PCRS: pcrs, Measurement.DEATHS: deaths}} self.assertEqual({ Measurement.PCRS: pcrs, Measurement.DEATHS: deaths }, get_global_data(data)) calculate_global_incidence_mock.assert_not_called()
def test_given_accumulated_incidence_when_global_data_then_calculate_global_incidence_returned( self, calculate_global_incidence_mock): ccaa1 = "Melilla" pcrs1 = 100 deaths1 = 4 ccaa2 = "Andalucia" pcrs2 = 400 deaths2 = 7 ia1 = 1.1 ia2 = 2.2 percentage_icu1 = 3.3 percentage_icu2 = 4.4 percentage_admitted1 = 5.5 percentage_admitted2 = 6.6 data = { ccaa1: { Measurement.PCRS: pcrs1, Measurement.DEATHS: deaths1, Measurement.ACCUMULATED_INCIDENCE: ia1, Measurement.PERCENTAGE_ICU: percentage_icu1, Measurement.PERCENTAGE_ADMITTED: percentage_admitted1 }, ccaa2: { Measurement.PCRS: pcrs2, Measurement.DEATHS: deaths2, Measurement.ACCUMULATED_INCIDENCE: ia2, Measurement.PERCENTAGE_ICU: percentage_icu2, Measurement.PERCENTAGE_ADMITTED: percentage_admitted2 } } self.assertEqual( { Measurement.PCRS: pcrs1 + pcrs2, Measurement.DEATHS: deaths1 + deaths2, Measurement.ACCUMULATED_INCIDENCE: calculate_global_incidence_mock.return_value, Measurement.PERCENTAGE_ADMITTED: calculate_global_incidence_mock.return_value, Measurement.PERCENTAGE_ICU: calculate_global_incidence_mock.return_value }, get_global_data(data)) calculate_global_incidence_mock.assert_has_calls([ call(data, Measurement.ACCUMULATED_INCIDENCE), call(data, Measurement.PERCENTAGE_ADMITTED), call(data, Measurement.PERCENTAGE_ICU) ])
def test_given_no_data_when_global_data_then_empty_dict_returned(self): self.assertEqual({}, get_global_data({}))