def test_sector_data_chart_data(self): data = get_prevalence_of_stunting_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.0 ] ], "key": "" } ] )
def test_sector_data_tooltips_data_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_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, icds_feature_flag=True ) self.assertDictEqual( data['tooltips_data'], { "s1": { "total": 71, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0 }, "s2": { "total": 153, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0 }, } )
def test_sector_data_chart_data(self): data = get_prevalence_of_stunting_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.5 ] ], "key": "" } ] )
def test_sector_data_tooltips_data(self): data = get_prevalence_of_stunting_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": 150, "severe": 0, "moderate": 2, "total_measured": 4, "normal": 2 }, "s1": { "total": 70, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0 } })
def test_sector_data_tooltips_data(self): data = get_prevalence_of_stunting_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": 153, "severe": 0, "moderate": 2, "total_measured": 4, "normal": 2 }, "s1": { "total": 71, "severe": 0, "moderate": 0, "total_measured": 0, "normal": 0 } } )
def test_sector_data_keys_length(self): data = get_prevalence_of_stunting_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(len(data), 3)
def test_sector_data_keys_length(self): data = get_prevalence_of_stunting_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(self): self.assertDictEqual( get_prevalence_of_stunting_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 (6-60 months) enrolled for ICDS services with height-for-age below" " -2Z standard deviations of the WHO Child Growth Standards median." "<br/><br/>Stunting is a sign of chronic undernutrition " "and has long lasting harmful consequences on the growth of a child", "tooltips_data": { "s2": { "total": 150, "severe": 0, "moderate": 2, "total_measured": 4, "normal": 2 }, "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.013333333333333334]], "key": "" }] })
def test_sector_data_info(self): data = get_prevalence_of_stunting_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( data['info'], "Of the children enrolled for Anganwadi services, whose height was measured, the percentage of " "children between (0 - 5 years) who were moderately/severely stunted in the current month. " "<br/><br/>" "Stunting is a sign of chronic undernutrition and has long lasting harmful " "consequences on the growth of a child")
def test_sector_data_info(self): data = get_prevalence_of_stunting_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 (6 - 60 months) enrolled for Anganwadi Services with height-for-age below" " -2Z standard deviations of the WHO Child Growth Standards median." "<br/><br/>Stunting is a sign of chronic undernutrition " "and has long lasting harmful consequences on the growth of a child" )
def test_sector_data_info(self): data = get_prevalence_of_stunting_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( data['info'], "Of the children enrolled for Anganwadi services, whose height was measured, the percentage of " "children between (0 - 5 years) who were moderately/severely stunted in the current month. " "<br/><br/>" "Stunting is a sign of chronic undernutrition and has long lasting harmful " "consequences on the growth of a child" )