def test_sector_data_chart_data(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor' ) self.assertListEqual( data['chart_data'], [ { "color": MapColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [["s1", 0.0], ["s2", 0.03296703296703297]], "key": "" } ] )
def test_sector_data_tooltips_data(self): data = get_prevalence_of_severe_sector_data('icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor') self.assertDictEqual( data['tooltips_data'], { "s2": { "total_weighed": 91, "severe": 0, "moderate": 3, "total_measured": 4, "normal": 1, "total_height_eligible": 153, }, "s1": { "total_weighed": 67, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0, "total_height_eligible": 71, } })
def test_sector_data_tooltips_data(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor' ) self.assertDictEqual( data['tooltips_data'], { "s2": { "total_weighed": 91, "severe": 0, "moderate": 3, "total_measured": 4, "normal": 1, "total_height_eligible": 153, }, "s1": { "total_weighed": 67, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0, "total_height_eligible": 71, } } )
def test_sector_data_chart_data(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor' ) self.assertListEqual( data['chart_data'], [ { "color": MapColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [["s1", 0.0], ["s2", 0.03296703296703297]], "key": "" } ] )
def test_sector_data(self): self.assertDictEqual( get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor' ), { "info": "Percentage of children between 6 - 60 months enrolled for ICDS services with " "weight-for-height below -3 standard deviations of the WHO Child Growth Standards" " median.<br/><br/>Severe Acute Malnutrition (SAM) or wasting in" " children is a symptom of acute undernutrition usually as " "a consequence of insufficient food intake or a high incidence of infectious diseases.", "tooltips_data": { "s2": { "total": 150, "severe": 0, "moderate": 3, "total_measured": 4, "normal": 1 }, "s1": { "total": 70, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0 } }, "chart_data": [ { "color": MapColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [ [ "s1", 0.0 ], [ "s2", 0.02 ] ], "key": "" } ] } )
def test_sector_data_keys_length(self): data = get_prevalence_of_severe_sector_data('icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor') self.assertEqual(len(data), 3)
def test_sector_data_keys_length(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor' ) self.assertEqual(len(data), 3)
def test_sector_data_info_icds_feature_flag_enabled(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor', show_test=False, ) self.assertEqual(data['info'], wasting_help_text("0 - 5 years"))
def test_sector_data_info_age_filter_5_years(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4, 'age_tranche': '60' }, location_id='b1', loc_level='supervisor', show_test=False, ) self.assertEqual(data['info'], wasting_help_text("48-60 months (1461-1825 days)"))
def test_sector_data_info_icds_feature_flag_enabled(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor', show_test=False, ) self.assertEqual( data['info'], wasting_help_text("0 - 5 years") )
def test_sector_data_info(self): data = get_prevalence_of_severe_sector_data('icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor') self.assertEquals( data['info'], "Percentage of children between 6 - 60 months enrolled for Anganwadi Services with " "weight-for-height below -3 standard deviations of the WHO Child Growth Standards" " median.<br/><br/>Severe Acute Malnutrition (SAM) or wasting in" " children is a symptom of acute undernutrition usually as " "a consequence of insufficient food intake or a high incidence of infectious diseases." )
def test_sector_data_info_age_filter_5_years(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4, 'age_tranche': '60' }, location_id='b1', loc_level='supervisor', show_test=False, ) self.assertEqual( data['info'], wasting_help_text("48-60 months (1461-1825 days)") )
def test_sector_data_info_icds_feature_flag_enabled(self): data = get_prevalence_of_severe_sector_data( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'block_id': 'b1', 'aggregation_level': 4 }, location_id='b1', loc_level='supervisor', show_test=False, ) self.assertEqual( data['info'], "Of the children enrolled for Anganwadi services, whose weight and height was measured, the " "percentage of children between 0 - 5 years enrolled who were moderately/severely wasted in the " "current month. " "<br/><br/>" "Severe Acute Malnutrition (SAM) or wasting in children is a symptom of acute undernutrition " "usually as a consequence of insufficient food intake or a high incidence of infectious diseases." )