def test_map_data_right_legend_extended_info(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['rightLegend']['extended_info'], [ { 'indicator': 'Total Number of Newborns born in given month:', 'value': "5" }, { 'indicator': 'Number of Newborns with LBW in given month:', 'value': "1" }, { 'indicator': 'Total Number of children born and weight in given month:', 'value': '3' }, { 'indicator': '% newborns with LBW in given month:', 'value': '33.33%' }, { 'indicator': '% of children with weight in normal:', 'value': '66.67%' }, { 'indicator': '% Unweighted:', 'value': '40.00%' }, ])
def test_map_data(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['data'], { 'st7': { 'in_month': 0, 'original_name': ['st7'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%' }, 'st1': { 'in_month': 2, 'original_name': ['st1'], 'low_birth': 1, 'all': 2, 'fillKey': '20%-60%' }, 'st2': { 'in_month': 1, 'original_name': ['st2'], 'low_birth': 0, 'all': 3, 'fillKey': '0%-20%' }, })
def test_map_data_slug(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(data['slug'], 'low_birth')
def test_map_data_right_legend_average(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(data['rightLegend']['average'], 33.333333333333336)
def test_map_data_right_legend_info(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = (new_born_with_low_weight_help_text(html=True)) self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_label(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(data['label'], 'Percent Newborns with Low Birth Weight')
def test_map_data(self): self.assertDictEqual( get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "rightLegend": { "info": "Percentage of newborns with born with birth weight less than 2500 grams." "<br/><br/>Newborns with Low Birth Weight are closely associated with foetal " "and neonatal mortality and morbidity, inhibited growth and cognitive development," " and chronic diseases later in life", "average": 25.0, 'extended_info': [{ 'indicator': 'Total Number of Newborns born in given month:', 'value': "7" }, { 'indicator': 'Number of Newborns with LBW in given month:', 'value': "2" }, { 'indicator': '% newborns with LBW in given month:', 'value': '28.57%' }, { 'indicator': '% Unweighed:', 'value': '71.43%' }] }, "fills": { "0%-20%": MapColors.PINK, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.RED, "defaultFill": MapColors.GREY }, "data": { "st1": { "in_month": 4, "low_birth": 2, 'original_name': ["st1"], "fillKey": "20%-60%" }, "st2": { "in_month": 3, "low_birth": 0, 'original_name': ["st2"], "fillKey": "0%-20%" } }, "slug": "low_birth", "label": "Percent Newborns with Low Birth Weight" })
def test_map_data_label(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['label'], 'Percent Newborns with Low Birth Weight')
def test_map_data_right_legend_average(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['rightLegend']['average'], 33.333333333333336)
def test_map_data_slug(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['slug'], 'low_birth')
def test_average_with_two_locations_represent_by_one_topojson(self): data = get_newborn_with_low_birth_weight_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'], 50.0)
def test_map_data_right_legend_keys(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state')['rightLegend'] self.assertEquals(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_newborn_with_low_birth_weight_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'], 50.0)
def test_map_data_right_legend_info(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) expected = ( new_born_with_low_weight_help_text(html=True) ) self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_right_legend_info(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = ( "Percentage of newborns with born with birth weight less than 2500 grams." "<br/><br/>Newborns with Low Birth Weight are closely associated with foetal " "and neonatal mortality and morbidity, inhibited growth and cognitive development," " and chronic diseases later in life") self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_right_legend_keys(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' )['rightLegend'] self.assertEquals(len(data), 3) self.assertIn('info', data) self.assertIn('average', data) self.assertIn('extended_info', data)
def test_map_data_keys(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(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_fills(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['fills'], { "0%-20%": MapColors.PINK, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.RED, "defaultFill": MapColors.GREY })
def test_map_data_keys(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(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_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = ( "Of all the children born in the current month and enrolled for Anganwadi services, the percentage " "that had a birth weight less than 2500 grams. " "<br/><br/>" "Newborns with Low Birth Weight are closely associated wtih foetal and neonatal mortality and " "morbidity, inhibited growth and cognitive development, and chronic diseases later in life. " ) self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_fills(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['fills'], { "0%-20%": MapColors.PINK, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.RED, "defaultFill": MapColors.GREY } )
def test_map_data_right_legend_extended_info(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['rightLegend']['extended_info'], [ {'indicator': 'Total Number of Newborns born in given month:', 'value': "5"}, {'indicator': 'Number of Newborns with LBW in given month:', 'value': "1"}, {'indicator': 'Total Number of children born and weight in given month:', 'value': '3'}, {'indicator': '% newborns with LBW in given month:', 'value': '33.33%'}, {'indicator': '% of children with weight in normal:', 'value': '66.67%'}, {'indicator': '% Unweighted:', 'value': '40.00%'}, ] )
def test_map_name_two_locations_represent_by_one_topojson(self): data = get_newborn_with_low_birth_weight_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': { 'in_month': 4, 'original_name': ['b1', 'b2'], 'low_birth': 2, 'fillKey': '20%-60%' } })
def test_map_data(self): data = get_newborn_with_low_birth_weight_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['data'], { 'st4': {'in_month': 0, 'original_name': ['st4'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%'}, 'st5': {'in_month': 0, 'original_name': ['st5'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%'}, 'st6': {'in_month': 0, 'original_name': ['st6'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%'}, 'st7': {'in_month': 0, 'original_name': ['st7'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%'}, 'st1': {'in_month': 2, 'original_name': ['st1'], 'low_birth': 1, 'all': 2, 'fillKey': '20%-60%'}, 'st2': {'in_month': 1, 'original_name': ['st2'], 'low_birth': 0, 'all': 3, 'fillKey': '0%-20%'}, 'st3': {'in_month': 0, 'original_name': ['st3'], 'low_birth': 0, 'all': 0, 'fillKey': '0%-20%'} } )
def test_map_data_right_legend_extended_info(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual( data['rightLegend']['extended_info'], [{ 'indicator': 'Total Number of Newborns born in given month:', 'value': "7" }, { 'indicator': 'Number of Newborns with LBW in given month:', 'value': "2" }, { 'indicator': '% newborns with LBW in given month:', 'value': '50.00%' }, { 'indicator': '% Unweighted:', 'value': '57.14%' }])
def test_map_data(self): data = get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['data'], { "st1": { "in_month": 4, "low_birth": 2, 'original_name': ["st1"], "fillKey": "20%-60%" }, "st2": { "in_month": 3, "low_birth": 0, 'original_name': ["st2"], "fillKey": "0%-20%" } })
def test_map_data(self): self.assertDictEqual( get_newborn_with_low_birth_weight_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state')[0], { "rightLegend": { "info": "Percentage of newborns with born with birth weight less than 2500 grams." "<br/><br/>Newborns with Low Birth Weight are closely associated with foetal " "and neonatal mortality and morbidity, inhibited growth and cognitive development," " and chronic diseases later in life", "average": 28.571428571428573 }, "fills": { "0%-20%": "#fee0d2", "20%-60%": "#fc9272", "60%-100%": "#de2d26", "defaultFill": "#9D9D9D" }, "data": { "st1": { "in_month": 4, "low_birth": 2, "fillKey": "20%-60%" }, "st2": { "in_month": 3, "low_birth": 0, "fillKey": "0%-20%" } }, "slug": "low_birth", "label": "Percent Newborns with Low Birth Weight" })
def test_map_name_two_locations_represent_by_one_topojson(self): data = get_newborn_with_low_birth_weight_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': { 'in_month': 2, 'original_name': ['b1', 'b2'], 'low_birth': 1, 'all': 2, 'fillKey': '20%-60%' } } )