def test_map_data_right_legend_extended_info(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['rightLegend']['extended_info'], [ {'indicator': 'Total Number of Children born in the given month:', 'value': "5"}, { 'indicator': ( 'Total Number of Children who were put to the breast within one hour of birth:' ), 'value': "2" }, { 'indicator': '% children who were put to the breast within one hour of birth:', 'value': '40.00%' } ] )
def test_map_data(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['data'], { "st1": { "in_month": 4, "birth": 3, 'original_name': ["st1"], "fillKey": "60%-100%" }, "st2": { "in_month": 3, "birth": 1, 'original_name': ["st2"], "fillKey": "20%-60%" } } )
def test_map_data_right_legend_extended_info(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['rightLegend']['extended_info'], [ {'indicator': 'Total Number of Children born in the given month:', 'value': "5"}, { 'indicator': ( 'Total Number of Children who were put to the breast within one hour of birth:' ), 'value': "2" }, { 'indicator': '% children who were put to the breast within one hour of birth:', 'value': '40.00%' } ] )
def test_map_data(self): self.assertDictEqual( get_early_initiation_breastfeeding_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "rightLegend": { "info": "Percentage of children who were put to the breast within one hour of birth." "<br/><br/>Early initiation of breastfeeding ensure the newborn " "recieves the 'first milk' rich in nutrients" " and encourages exclusive breastfeeding practice", "average": 57.142857142857146, 'extended_info': [{ 'indicator': 'Total Number of Children born in the given month:', 'value': "7" }, { 'indicator': ('Total Number of Children who were put to the breast within one hour of birth:' ), 'value': "4" }, { 'indicator': '% children who were put to the breast within one hour of birth:', 'value': '57.14%' }] }, "fills": { "0%-20%": MapColors.RED, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.PINK, "defaultFill": MapColors.GREY }, "data": { "st1": { "in_month": 4, "birth": 3, 'original_name': ["st1"], "fillKey": "60%-100%" }, "st2": { "in_month": 3, "birth": 1, 'original_name': ["st2"], "fillKey": "20%-60%" } }, "slug": "early_initiation", "label": "Percent Early Initiation of Breastfeeding" })
def test_map_data_right_legend_average(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['rightLegend']['average'], 40.0)
def test_map_data_right_legend_average(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['rightLegend']['average'], 40.0)
def test_map_data_slug(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['slug'], 'early_initiation')
def test_map_data_label(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['label'], 'Percent Early Initiation of Breastfeeding')
def test_map_data_label(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['label'], 'Percent Early Initiation of Breastfeeding')
def test_map_data_slug(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['slug'], 'early_initiation')
def test_map_data_right_legend_info(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) expected = early_initiation_breastfeeding_help_text(html=True) self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_right_legend_info(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) expected = early_initiation_breastfeeding_help_text(html=True) self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data(self): data = get_early_initiation_breastfeeding_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'], 'birth': 0, 'fillKey': '0%-20%' }, 'st5': { 'in_month': 0, 'original_name': ['st5'], 'birth': 0, 'fillKey': '0%-20%' }, 'st6': { 'in_month': 0, 'original_name': ['st6'], 'birth': 0, 'fillKey': '0%-20%' }, 'st7': { 'in_month': 0, 'original_name': ['st7'], 'birth': 0, 'fillKey': '0%-20%' }, 'st1': { 'in_month': 2, 'original_name': ['st1'], 'birth': 1, 'fillKey': '20%-60%' }, 'st2': { 'in_month': 3, 'original_name': ['st2'], 'birth': 1, 'fillKey': '20%-60%' }, 'st3': { 'in_month': 0, 'original_name': ['st3'], 'birth': 0, 'fillKey': '0%-20%' } })
def test_map_name_is_different_data(self): self.assertDictEqual( get_early_initiation_breastfeeding_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 who were put to the breast within one hour of birth." "<br/><br/>Early initiation of breastfeeding ensure the newborn " "recieves the 'first milk' rich in nutrients" " and encourages exclusive breastfeeding practice", "average": 75.0, 'extended_info': [{ 'indicator': 'Total Number of Children born in the given month:', 'value': "4" }, { 'indicator': ('Total Number of Children who were put to the breast within one hour of birth:' ), 'value': "3" }, { 'indicator': '% children who were put to the breast within one hour of birth:', 'value': '75.00%' }] }, "fills": { "0%-20%": MapColors.RED, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.PINK, "defaultFill": MapColors.GREY }, "data": { 'block_map': { 'in_month': 4, 'original_name': ['b1', 'b2'], 'birth': 3, 'fillKey': '60%-100%' } }, "slug": "early_initiation", "label": "Percent Early Initiation of Breastfeeding" })
def test_average_with_two_locations_represent_by_one_topojson(self): data = get_early_initiation_breastfeeding_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_early_initiation_breastfeeding_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_early_initiation_breastfeeding_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_name_two_locations_represent_by_one_topojson(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 1 }, loc_level='block', ) self.assertDictEqual(data['data'], {})
def test_map_data_right_legend_keys(self): data = get_early_initiation_breastfeeding_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_early_initiation_breastfeeding_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_name_two_locations_represent_by_one_topojson(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'state_id': 'st1', 'district_id': 'd1', 'aggregation_level': 1 }, loc_level='block', ) self.assertDictEqual( data['data'], {} )
def test_map_data_keys(self): data = get_early_initiation_breastfeeding_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_early_initiation_breastfeeding_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') expected = ( "Percentage of children who were put to the breast within one hour of birth." "<br/><br/>Early initiation of breastfeeding ensure the newborn " "recieves the 'first milk' rich in nutrients" " and encourages exclusive breastfeeding practice") self.assertEquals(data['rightLegend']['info'], expected)
def test_map_data_fills(self): data = get_early_initiation_breastfeeding_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertDictEqual( data['fills'], { "0%-20%": MapColors.RED, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.PINK, "defaultFill": MapColors.GREY })
def test_map_data_fills(self): data = get_early_initiation_breastfeeding_map( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertDictEqual( data['fills'], { "0%-20%": MapColors.RED, "20%-60%": MapColors.ORANGE, "60%-100%": MapColors.PINK, "defaultFill": MapColors.GREY } )
def test_map_name_two_locations_represent_by_one_topojson(self): data = get_early_initiation_breastfeeding_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'], 'birth': 3, 'fillKey': '60%-100%' } })
def test_map_data(self): data = get_early_initiation_breastfeeding_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'], 'birth': 0, 'fillKey': '0%-20%'}, 'st5': {'in_month': 0, 'original_name': ['st5'], 'birth': 0, 'fillKey': '0%-20%'}, 'st6': {'in_month': 0, 'original_name': ['st6'], 'birth': 0, 'fillKey': '0%-20%'}, 'st7': {'in_month': 0, 'original_name': ['st7'], 'birth': 0, 'fillKey': '0%-20%'}, 'st1': {'in_month': 2, 'original_name': ['st1'], 'birth': 1, 'fillKey': '20%-60%'}, 'st2': {'in_month': 3, 'original_name': ['st2'], 'birth': 1, 'fillKey': '20%-60%'}, 'st3': {'in_month': 0, 'original_name': ['st3'], 'birth': 0, 'fillKey': '0%-20%'} } )
def test_map_data(self): self.assertDictEqual( get_early_initiation_breastfeeding_map('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state')[0], { "rightLegend": { "info": "Percentage of children who were put to the breast within one hour of birth." "<br/><br/>Early initiation of breastfeeding ensure the newborn " "recieves the 'first milk' rich in nutrients" " and encourages exclusive breastfeeding practice", "average": 57.142857142857146 }, "fills": { "0%-20%": "#de2d26", "20%-60%": "#fc9272", "60%-100%": "#fee0d2", "defaultFill": "#9D9D9D" }, "data": { "st1": { "in_month": 4, "birth": 3, "fillKey": "60%-100%" }, "st2": { "in_month": 3, "birth": 1, "fillKey": "20%-60%" } }, "slug": "early_initiation", "label": "Percent Early Initiation of Breastfeeding" })
def test_map_name_two_locations_represent_by_one_topojson(self): data = get_early_initiation_breastfeeding_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'], 'birth': 3, 'fillKey': '60%-100%' } } )