示例#1
0
 def test_map_name_two_locations_represent_by_one_topojson(self):
     data = get_adult_weight_scale_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": {
                 "in_month": 5,
                 "original_name": [
                     "b1",
                     "b2"
                 ],
                 "all": 17,
                 "fillKey": "25%-75%"
             }
         }
     )
示例#2
0
 def test_map_data_slug(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertEquals(data['slug'], 'adult_weight_scale')
示例#3
0
 def test_map_data_right_legend_average(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertEquals(data['rightLegend']['average'], 30.0)
示例#4
0
 def test_map_data_label(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertEquals(data['label'],
                       'Percentage of AWCs that reported having a weighing scale for mother and child')
示例#5
0
 def test_map_data_right_legend_info(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     expected = awcs_reported_weighing_scale_mother_and_child_help_text()
     self.assertEquals(data['rightLegend']['info'], expected)
示例#6
0
 def test_average_with_two_locations_represent_by_one_topojson(self):
     data = get_adult_weight_scale_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'], 29.41176470588235)
示例#7
0
 def test_map_data_right_legend_keys(self):
     data = get_adult_weight_scale_data_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)
示例#8
0
 def test_map_data_fills(self):
     data = get_adult_weight_scale_data_map('icds-cas',
                                            config={
                                                'month': (2017, 5, 1),
                                                'aggregation_level': 1
                                            },
                                            loc_level='state')
     self.assertDictEqual(
         data['fills'], {
             "0%-25%": MapColors.RED,
             "25%-75%": MapColors.ORANGE,
             "75%-100%": MapColors.PINK,
             "defaultFill": MapColors.GREY
         })
 def test_map_data_keys(self):
     data = get_adult_weight_scale_data_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)
示例#10
0
 def test_map_data(self):
     self.assertDictEqual(
         get_adult_weight_scale_data_map('icds-cas',
                                         config={
                                             'month': (2017, 5, 1),
                                             'aggregation_level': 1
                                         },
                                         loc_level='state'),
         {
             "rightLegend": {
                 "info":
                 "Percentage of AWCs that reported having a weighing scale for mother and child",
                 "average":
                 30.09049773755656,
                 'extended_info': [{
                     'indicator':
                     'Total number of AWCs with a weighing scale for mother and child:',
                     'value': "9"
                 }, {
                     'indicator':
                     '% of AWCs with a weighing scale for mother and child:',
                     'value': '30.00%'
                 }]
             },
             "label":
             "Percentage of AWCs that reported having a weighing scale for mother and child",
             "data": {
                 "st1": {
                     "in_month": 5,
                     "original_name": ["st1"],
                     "all": 17,
                     "fillKey": "25%-75%"
                 },
                 "st2": {
                     "in_month": 4,
                     "original_name": ["st2"],
                     "all": 13,
                     "fillKey": "25%-75%"
                 }
             },
             "slug": "adult_weight_scale",
             "fills": {
                 "0%-25%": MapColors.RED,
                 "25%-75%": MapColors.ORANGE,
                 "75%-100%": MapColors.PINK,
                 "defaultFill": MapColors.GREY
             }
         })
 def test_map_name_is_different_data(self):
     self.assertDictEqual(
         get_adult_weight_scale_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 AWCs that reported having a weighing scale for mother and child",
                 "average": 29.41176470588235,
                 'extended_info': [
                     {
                         'indicator': 'Total number of AWCs with a weighing scale for mother and child:',
                         'value': "5"
                     },
                     {'indicator': '% of AWCs with a weighing scale for mother and child:', 'value': '29.41%'}
                 ]
             },
             "label": "Percentage of AWCs that reported having a weighing scale for mother and child",
             "data": {
                 "block_map": {
                     "in_month": 5,
                     "original_name": [
                         "b1",
                         "b2"
                     ],
                     "all": 17,
                     "fillKey": "25%-75%"
                 }
             },
             "slug": "adult_weight_scale",
             "fills": {
                 "0%-25%": MapColors.RED,
                 "25%-75%": MapColors.ORANGE,
                 "75%-100%": MapColors.PINK,
                 "defaultFill": MapColors.GREY
             }
         }
     )
 def test_map_data_right_legend_extended_info(self):
     data = get_adult_weight_scale_data_map('icds-cas',
                                            config={
                                                'month': (2017, 5, 1),
                                                'aggregation_level': 1
                                            },
                                            loc_level='state')
     self.assertListEqual(data['rightLegend']['extended_info'], [{
         'indicator':
         'Total number of AWCs with a weighing scale for mother and child:',
         'value':
         "9"
     }, {
         'indicator':
         '% of AWCs with a weighing scale for mother and child:',
         'value':
         '30.00%'
     }])
示例#13
0
 def test_map_data_fills(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertDictEqual(
         data['fills'],
         {
             "0%-25%": MapColors.RED,
             "25%-75%": MapColors.ORANGE,
             "75%-100%": MapColors.PINK,
             "defaultFill": MapColors.GREY
         }
     )
示例#14
0
 def test_map_data_right_legend_extended_info(self):
     data = get_adult_weight_scale_data_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['rightLegend']['extended_info'],
         [
             {
                 'indicator': 'Total number of AWCs with a weighing scale for mother and child:',
                 'value': "9"
             },
             {'indicator': '% of AWCs with a weighing scale for mother and child:', 'value': '30.00%'}
         ]
     )
 def test_map_name_two_locations_represent_by_one_topojson(self):
     data = get_adult_weight_scale_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": {
                 "in_month": 5,
                 "original_name": ["b1", "b2"],
                 "all": 17,
                 "fillKey": "25%-75%"
             }
         })
 def test_map_data(self):
     data = get_adult_weight_scale_data_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'], 'all': 0, 'fillKey': '0%-25%'},
          'st5': {'in_month': 0, 'original_name': ['st5'], 'all': 0, 'fillKey': '0%-25%'},
          'st6': {'in_month': 0, 'original_name': ['st6'], 'all': 0, 'fillKey': '0%-25%'},
          'st7': {'in_month': 0, 'original_name': ['st7'], 'all': 0, 'fillKey': '0%-25%'},
          'st1': {'in_month': 5, 'original_name': ['st1'], 'all': 17, 'fillKey': '25%-75%'},
          'st2': {'in_month': 4, 'original_name': ['st2'], 'all': 13, 'fillKey': '25%-75%'},
          'st3': {'in_month': 0, 'original_name': ['st3'], 'all': 0, 'fillKey': '0%-25%'}
          },
     )
 def test_map_data(self):
     data = get_adult_weight_scale_data_map('icds-cas',
                                            config={
                                                'month': (2017, 5, 1),
                                                'aggregation_level': 1
                                            },
                                            loc_level='state')
     self.assertDictEqual(
         data['data'], {
             "st1": {
                 "in_month": 5,
                 "original_name": ["st1"],
                 "all": 17,
                 "fillKey": "25%-75%"
             },
             "st2": {
                 "in_month": 4,
                 "original_name": ["st2"],
                 "all": 13,
                 "fillKey": "25%-75%"
             }
         })