コード例 #1
0
 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%'
             }
         ]
     )
コード例 #2
0
 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%"
             }
         }
     )
コード例 #3
0
 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%'
             }
         ]
     )
コード例 #4
0
 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"
         })
コード例 #5
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)
コード例 #6
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)
コード例 #7
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')
コード例 #8
0
 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')
コード例 #9
0
 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')
コード例 #10
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')
コード例 #11
0
 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)
コード例 #12
0
 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)
コード例 #13
0
 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%'
             }
         })
コード例 #14
0
 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"
         })
コード例 #15
0
 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)
コード例 #16
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)
コード例 #17
0
 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)
コード例 #18
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'], {})
コード例 #19
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)
コード例 #20
0
 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)
コード例 #21
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'],
         {}
     )
コード例 #22
0
 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)
コード例 #23
0
 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)
コード例 #24
0
 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
         })
コード例 #25
0
 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
         }
     )
コード例 #26
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': 3
         },
         loc_level='block',
     )
     self.assertDictEqual(
         data['data'], {
             'block_map': {
                 'in_month': 4,
                 'original_name': ['b1', 'b2'],
                 'birth': 3,
                 'fillKey': '60%-100%'
             }
         })
コード例 #27
0
 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"
         })
コード例 #29
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': 3
         },
         loc_level='block',
     )
     self.assertDictEqual(
         data['data'],
         {
             'block_map': {
                 'in_month': 4,
                 'original_name': ['b1', 'b2'],
                 'birth': 3,
                 'fillKey': '60%-100%'
             }
         }
     )