def test_map_name_two_locations_represent_by_one_topojson(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', ) self.assertDictEqual( data['data'], { 'block_map': { 'moderate': 3, 'total_measured': 7, 'normal': 2, 'original_name': ['b1', 'b2'], 'severe': 2, 'total': 454, 'fillKey': '38%-100%' } } )
def test_map_name_two_locations_represent_by_one_topojson_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', show_test=False, icds_feature_flag=True ) self.assertDictEqual( data['data'], { 'block_map': { 'moderate': 0, 'total_measured': 0, 'normal': 0, 'original_name': ['b1', 'b2'], 'severe': 0, 'total': 454, 'fillKey': '0%-25%' } } )
def test_map_data(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['data'], { "st1": { "severe": 0, "moderate": 0, "normal": 0, "total_measured": 0, "total": 449, 'original_name': ["st1"], "fillKey": "0%-25%" }, "st2": { "severe": 0, "moderate": 0, "normal": 0, "total_measured": 0, "total": 490, 'original_name': ["st2"], "fillKey": "0%-25%" } } )
def test_map_name_two_locations_represent_by_one_topojson(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', ) self.assertDictEqual( data['data'], { 'block_map': { 'moderate': 3, 'total_measured': 7, 'normal': 2, 'original_name': ['b1', 'b2'], 'severe': 2, 'total': 454, 'fillKey': '38%-100%' } } )
def test_map_data_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state', show_test=False, icds_feature_flag=True ) self.assertDictEqual( data['data'], { "st1": { "severe": 0, "moderate": 0, "normal": 0, "total_measured": 0, "total": 454, 'original_name': ["st1"], "fillKey": "0%-25%" }, "st2": { "severe": 0, "moderate": 0, "normal": 0, "total_measured": 0, "total": 497, 'original_name': ["st2"], "fillKey": "0%-25%" } } )
def test_map_data_right_legend_average(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEqual(data['rightLegend']['average'], "59.38")
def test_map_data_slug(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEqual(data['slug'], 'severe')
def test_map_data_label(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEqual(data['label'], 'Percent of Children Stunted (0 - 5 years)')
def test_map_data_label(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEqual(data['label'], 'Percent of Children Stunted (0 - 5 years)')
def test_map_data_right_legend_average(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEqual(data['rightLegend']['average'], "59.38")
def test_map_data_slug(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEqual(data['slug'], 'severe')
def test_map_data_right_legend_average_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state', show_test=False, icds_feature_flag=True) self.assertEquals(data['rightLegend']['average'], "0.00")
def test_map_data_label_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state', show_test=False, icds_feature_flag=True) self.assertEquals(data['label'], 'Percent of Children Stunted (0 - 5 years)')
def test_average_with_two_locations_represent_by_one_topojson(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', ) self.assertEqual(data['rightLegend']['average'], "71.43")
def test_map_data_right_legend_keys(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state')['rightLegend'] self.assertEqual(len(data), 3) self.assertIn('info', data) self.assertIn('average', data) self.assertIn('extended_info', data)
def test_average_with_two_locations_represent_by_one_topojson(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', ) self.assertEquals(data['rightLegend']['average'], "0.00")
def test_map_data_right_legend_keys(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' )['rightLegend'] self.assertEqual(len(data), 3) self.assertIn('info', data) self.assertIn('average', data) self.assertIn('extended_info', data)
def test_map_data_keys(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEqual(len(data), 5) self.assertIn('rightLegend', data) self.assertIn('fills', data) self.assertIn('data', data) self.assertIn('slug', data) self.assertIn('label', data)
def test_map_data_right_legend_info(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = ( "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") self.assertEqual(data['rightLegend']['info'], expected)
def test_map_data_right_legend_info(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = ( "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") self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_fills(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['fills'], { "0%-25%": MapColors.PINK, "25%-38%": MapColors.ORANGE, "38%-100%": MapColors.RED, "defaultFill": MapColors.GREY })
def test_map_data_keys(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEqual(len(data), 5) self.assertIn('rightLegend', data) self.assertIn('fills', data) self.assertIn('data', data) self.assertIn('slug', data) self.assertIn('label', data)
def test_map_data_right_legend_info(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) expected = ( "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" ) self.assertEqual(data['rightLegend']['info'], expected)
def test_map_data_fills(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['fills'], { "0%-25%": MapColors.PINK, "25%-38%": MapColors.ORANGE, "38%-100%": MapColors.RED, "defaultFill": MapColors.GREY } )
def test_map_data_right_legend_extended_info_icds_feature_flag_enabled( self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state', show_test=False, icds_feature_flag=True) self.assertListEqual(data['rightLegend']['extended_info'], [{ 'indicator': 'Total Children (0 - 5 years) eligible to have height measured:', 'value': '951' }, { 'indicator': 'Total Children (0 - 5 years) with height measured in given month:', 'value': '32' }, { 'indicator': 'Number of Children (0 - 5 years) unmeasured:', 'value': '919' }, { 'indicator': '% children (0 - 5 years) with severely stunted growth:', 'value': '0.00%' }, { 'indicator': '% children (0 - 5 years) with moderate stunted growth:', 'value': '0.00%' }, { 'indicator': '% children (0 - 5 years) with normal stunted growth:', 'value': '0.00%' }])
def test_map_data_right_legend_extended_info(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['rightLegend']['extended_info'], [ {'indicator': 'Total Children (0 - 5 years) eligible to have height measured:', 'value': '952'}, {'indicator': 'Total Children (0 - 5 years) with height measured in given month:', 'value': '32'}, {'indicator': 'Number of Children (0 - 5 years) unmeasured:', 'value': '920'}, {'indicator': '% children (0 - 5 years) with severely stunted growth:', 'value': '34.38%'}, {'indicator': '% children (0 - 5 years) with moderate stunted growth:', 'value': '25.00%'}, {'indicator': '% children (0 - 5 years) with normal stunted growth:', 'value': '40.62%'} ] )
def test_map_data_right_legend_extended_info(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['rightLegend']['extended_info'], [{ 'indicator': 'Total Children (6 - 60 months) eligible to have height measured:', 'value': '939' }, { 'indicator': 'Total Children (6 - 60 months) with height measured in given month:', 'value': '32' }, { 'indicator': '% Unmeasured (6 - 60 months):', 'value': '96.59%' }, { 'indicator': '% Severely stunted (6 - 60 months):', 'value': '34.38%' }, { 'indicator': '% Moderately stunted (6 - 60 months):', 'value': '25.00%' }, { 'indicator': '% Normal (6 - 60 months):', 'value': '40.62%' }])
def test_map_data_right_legend_extended_info(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['rightLegend']['extended_info'], [{ 'indicator': 'Total Children (0 - 5 years) eligible to have height measured:', 'value': '989' }, { 'indicator': 'Total Children (0 - 5 years) with height measured in given month:', 'value': '32' }, { 'indicator': 'Number of Children (0 - 5 years) with height unmeasured:', 'value': '957' }, { 'indicator': '% children (0 - 5 years) with severely stunted growth:', 'value': '34.38%' }, { 'indicator': '% children (0 - 5 years) with moderate stunted growth:', 'value': '25.00%' }, { 'indicator': '% children (0 - 5 years) with normal height-for-age:', 'value': '40.62%' }])
def test_map_data(self): data = get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['data'], { 'st1': { 'moderate': 3, 'severe': 2, 'normal': 2, 'total': 475, 'total_measured': 7, 'original_name': ['st1'], 'fillKey': '38%-100%' }, 'st2': { 'moderate': 5, 'severe': 9, 'normal': 11, 'total': 513, 'total_measured': 25, 'original_name': ['st2'], 'fillKey': '38%-100%' }, 'st7': { 'moderate': 0, 'severe': 0, 'normal': 0, 'total': 1, 'total_measured': 0, 'original_name': ['st7'], 'fillKey': '0%-25%' } })
def test_map_data(self): self.assertDictEqual( get_prevalence_of_stunting_data_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "rightLegend": { "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", "average": "2.73", 'extended_info': [{ 'indicator': 'Total Children (6 - 60 months) weighed in given month:', 'value': '939' }, { 'indicator': 'Total Children (6 - 60 months) with height measured in given month:', 'value': '32' }, { 'indicator': '% Unmeasured (6 - 60 months):', 'value': '95.63%' }, { 'indicator': '% Severely stunted (6 - 60 months):', 'value': '1.70%' }, { 'indicator': '% Moderately stunted (6 - 60 months):', 'value': '1.06%' }, { 'indicator': '% Normal (6 - 60 months):', 'value': '1.60%' }] }, "fills": { "0%-25%": MapColors.PINK, "25%-38%": MapColors.ORANGE, "38%-100%": MapColors.RED, "defaultFill": MapColors.GREY }, "data": { "st1": { "severe": 3, "moderate": 5, "normal": 2, "total_measured": 7, "total": 449, 'original_name': ["st1"], "fillKey": "0%-25%" }, "st2": { "severe": 13, "moderate": 5, "normal": 13, "total_measured": 25, "total": 490, 'original_name': ["st2"], "fillKey": "0%-25%" } }, "slug": "severe", "label": "Percent of Children Stunted (6 - 60 months)" })
def test_map_name_is_different_data(self): self.assertDictEqual( get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 3 }, loc_level='block', ), { "rightLegend": { "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", "average": "1.78", 'extended_info': [{ 'indicator': 'Total Children (6 - 60 months) weighed in given month:', 'value': '449' }, { 'indicator': 'Total Children (6 - 60 months) with height measured in given month:', 'value': '7' }, { 'indicator': '% Unmeasured (6 - 60 months):', 'value': '97.77%' }, { 'indicator': '% Severely stunted (6 - 60 months):', 'value': '0.67%' }, { 'indicator': '% Moderately stunted (6 - 60 months):', 'value': '1.11%' }, { 'indicator': '% Normal (6 - 60 months):', 'value': '0.45%' }] }, "fills": { "0%-25%": MapColors.PINK, "25%-38%": MapColors.ORANGE, "38%-100%": MapColors.RED, "defaultFill": MapColors.GREY }, "data": { 'block_map': { 'moderate': 5, 'total_measured': 7, 'normal': 2, 'original_name': ['b1', 'b2'], 'severe': 3, 'total': 449, 'fillKey': '0%-25%' } }, "slug": "severe", "label": "Percent of Children Stunted (6 - 60 months)" })
def test_map_data(self): data = get_prevalence_of_stunting_data_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['data'], { 'st4': { 'moderate': 0, 'normal': 0, 'total_measured': 0, 'original_name': ['st4'], 'severe': 0, 'total': 0, 'fillKey': '0%-25%' }, 'st5': { 'moderate': 0, 'normal': 0, 'total_measured': 0, 'original_name': ['st5'], 'severe': 0, 'total': 0, 'fillKey': '0%-25%' }, 'st6': { 'moderate': 0, 'normal': 0, 'total_measured': 0, 'original_name': ['st6'], 'severe': 0, 'total': 0, 'fillKey': '0%-25%' }, 'st7': { 'moderate': 0, 'normal': 0, 'total_measured': 0, 'original_name': ['st7'], 'severe': 0, 'total': 1, 'fillKey': '0%-25%' }, 'st1': { 'moderate': 3, 'normal': 2, 'total_measured': 7, 'original_name': ['st1'], 'severe': 2, 'total': 454, 'fillKey': '38%-100%' }, 'st2': { 'moderate': 5, 'normal': 11, 'total_measured': 25, 'original_name': ['st2'], 'severe': 9, 'total': 497, 'fillKey': '38%-100%' }, 'st3': { 'moderate': 0, 'normal': 0, 'total_measured': 0, 'original_name': ['st3'], 'severe': 0, 'total': 0, 'fillKey': '0%-25%' } } )