def test_chart_data_location_type(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertEqual(data['location_type'], 'State')
 def test_chart_data_elements_length(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertEqual(len(data['chart_data']), 3)
 def test_chart_data_pink_icds_feature_flag_enabled(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state',
         show_test=False,
         icds_feature_flag=True
     )
     self.assertDictEqual(
         data['chart_data'][0],
         {
             "color": ChartColors.PINK,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0
                 },
                 {
                     "y": 0.6666666666666666,
                     "x": 1491004800000,
                     "total_weighed": 691,
                     'total_measured': 9,
                     'total_height_eligible': 981,
                 },
                 {
                     "y": 0.7037037037037037,
                     "x": 1493596800000,
                     "total_weighed": 696,
                     'total_measured': 27,
                     'total_height_eligible': 952,
                 }
             ],
             "key": "% normal"
         }
     )
 def test_chart_data_orange_icds_feature_flag_enabled(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state',
         show_test=False,
         icds_feature_flag=True
     )
     self.assertDictEqual(
         data['chart_data'][1],
         {
             "color": ChartColors.ORANGE,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0,
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0,
                 },
                 {
                     "y": 0.1111111111111111,
                     "x": 1491004800000,
                     "total_weighed": 691,
                     'total_measured': 9,
                     'total_height_eligible': 981,
                 },
                 {
                     "y": 0.2962962962962963,
                     "x": 1493596800000,
                     "total_weighed": 696,
                     'total_measured': 27,
                     'total_height_eligible': 952,
                 }
             ],
             "key": "% moderately wasted (moderate acute malnutrition)"
         }
     )
 def test_chart_data_red(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertDictEqual(
         data['chart_data'][2],
         {
             "color": ChartColors.RED,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "total_weighed": 0,
                     'total_measured': 0,
                     'total_height_eligible': 0
                 },
                 {
                     "y": 0.2222222222222222,
                     "x": 1491004800000,
                     "total_weighed": 691,
                     'total_measured': 9,
                     'total_height_eligible': 981,
                 },
                 {
                     "y": 0.0,
                     "x": 1493596800000,
                     "total_weighed": 696,
                     'total_measured': 27,
                     'total_height_eligible': 952,
                 }
             ],
             "key": "% severely wasted (severe acute malnutrition)"
         }
     )
 def test_chart_data_bottom_five(self):
     data = get_prevalence_of_severe_data_chart('icds-cas',
                                                config={
                                                    'month': (2017, 5, 1),
                                                    'aggregation_level': 1
                                                },
                                                loc_level='state')
     self.assertListEqual(data['bottom_five'],
                          [{
                              'loc_name': 'st7',
                              'percent': 0.0
                          }, {
                              'loc_name': 'st2',
                              'percent': 20.0
                          }, {
                              'loc_name': 'st1',
                              'percent': 57.142857142857146
                          }])
 def test_chart_data_all_locations_icds_feature_flag_enabled(self):
     data = get_prevalence_of_severe_data_chart('icds-cas',
                                                config={
                                                    'month': (2017, 5, 1),
                                                    'aggregation_level': 1
                                                },
                                                loc_level='state',
                                                show_test=False,
                                                icds_feature_flag=True)
     self.assertListEqual(data['all_locations'], [
         {
             "loc_name": "st1",
             "percent": 0.0
         },
         {
             "loc_name": "st2",
             "percent": 4.166666666666667,
         },
     ])
 def test_chart_data_orange(self):
     data = get_prevalence_of_severe_data_chart('icds-cas',
                                                config={
                                                    'month': (2017, 5, 1),
                                                    'aggregation_level': 1
                                                },
                                                loc_level='state')
     self.assertDictEqual(
         data['chart_data'][1], {
             "color":
             ChartColors.ORANGE,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0,
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0,
             }, {
                 "y": 0.08333333333333333,
                 "x": 1491004800000,
                 "total_weighed": 690,
                 'total_measured': 12,
                 'total_height_eligible': 1021,
             }, {
                 "y": 0.25806451612903225,
                 "x": 1493596800000,
                 "total_weighed": 695,
                 'total_measured': 31,
                 'total_height_eligible': 989,
             }],
             "key":
             "% moderately wasted (moderate acute malnutrition)"
         })
Exemple #9
0
 def test_chart_data_red(self):
     data = get_prevalence_of_severe_data_chart('icds-cas',
                                                config={
                                                    'month': (2017, 5, 1),
                                                    'aggregation_level': 1
                                                },
                                                loc_level='state')
     self.assertDictEqual(
         data['chart_data'][2], {
             "color":
             ChartColors.RED,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0
             }, {
                 "y": 0.2222222222222222,
                 "x": 1491004800000,
                 "total_weighed": 691,
                 'total_measured': 9,
                 'total_height_eligible': 981,
             }, {
                 "y": 0.0,
                 "x": 1493596800000,
                 "total_weighed": 696,
                 'total_measured': 27,
                 'total_height_eligible': 952,
             }],
             "key":
             "% severely wasted (severe acute malnutrition)"
         })
 def test_chart_data_top_five(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['top_five'],
         [
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st4', 'percent': 0.0},
             {'loc_name': 'st5', 'percent': 0.0},
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0}
         ]
     )
 def test_chart_data_top_five(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['top_five'],
         [
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st4', 'percent': 0.0},
             {'loc_name': 'st5', 'percent': 0.0},
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0}
         ]
     )
 def test_chart_data_pink(self):
     data = get_prevalence_of_severe_data_chart('icds-cas',
                                                config={
                                                    'month': (2017, 5, 1),
                                                    'aggregation_level': 1
                                                },
                                                loc_level='state')
     self.assertDictEqual(
         data['chart_data'][0], {
             "color":
             ChartColors.PINK,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "total_weighed": 0,
                 'total_measured': 0,
                 'total_height_eligible': 0
             }, {
                 "y": 0.5,
                 "x": 1491004800000,
                 "total_weighed": 690,
                 'total_measured': 12,
                 'total_height_eligible': 1021,
             }, {
                 "y": 0.6129032258064516,
                 "x": 1493596800000,
                 "total_weighed": 695,
                 'total_measured': 31,
                 'total_height_eligible': 989,
             }],
             "key":
             "% normal"
         })
 def test_chart_data_all_locations(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['all_locations'],
         [
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st4', 'percent': 0.0},
             {'loc_name': 'st5', 'percent': 0.0},
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0},
             {'loc_name': 'st2', 'percent': 20.0},
             {'loc_name': 'st1', 'percent': 57.142857142857146}
         ]
     )
 def test_chart_data_top_five_icds_feature_flag_enabled(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state',
         show_test=False,
         icds_feature_flag=True
     )
     self.assertListEqual(
         data['top_five'],
         [
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st4', 'percent': 0.0},
             {'loc_name': 'st5', 'percent': 0.0},
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0}
         ]
     )
 def test_chart_data_top_five_icds_feature_flag_enabled(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state',
         show_test=False,
         icds_feature_flag=True
     )
     self.assertListEqual(
         data['top_five'],
         [
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st4', 'percent': 0.0},
             {'loc_name': 'st5', 'percent': 0.0},
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0}
         ]
     )
 def test_chart_data_all_locations(self):
     data = get_prevalence_of_severe_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['all_locations'],
         [
             {
                 "loc_name": "st2",
                 "percent": 16.666666666666668,
             },
             {
                 "loc_name": "st1",
                 "percent": 57.142857142857146
             },
         ]
     )
Exemple #17
0
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_severe_data_chart('icds-cas',
                                             config={
                                                 'month': (2017, 5, 1),
                                                 'aggregation_level': 1
                                             },
                                             loc_level='state'),
         {
             "location_type":
             "State",
             "bottom_five": [
                 {
                     "loc_name": "st2",
                     "percent": 16.666666666666668
                 },
                 {
                     "loc_name": "st1",
                     "percent": 57.142857142857146
                 },
             ],
             "top_five": [
                 {
                     "loc_name": "st2",
                     "percent": 16.666666666666668,
                 },
                 {
                     "loc_name": "st1",
                     "percent": 57.142857142857146
                 },
             ],
             "chart_data": [{
                 "color":
                 ChartColors.PINK,
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.5454545454545454,
                     "x": 1491004800000,
                     "all": 11
                 }, {
                     "y": 0.6129032258064516,
                     "x": 1493596800000,
                     "all": 31
                 }],
                 "key":
                 "% normal"
             }, {
                 "color":
                 ChartColors.ORANGE,
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.09090909090909091,
                     "x": 1491004800000,
                     "all": 11
                 }, {
                     "y": 0.25806451612903225,
                     "x": 1493596800000,
                     "all": 31
                 }],
                 "key":
                 "% moderately wasted (moderate acute malnutrition)"
             }, {
                 "color":
                 ChartColors.RED,
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.09090909090909091,
                     "x": 1491004800000,
                     "all": 11
                 }, {
                     "y": 0.0,
                     "x": 1493596800000,
                     "all": 31
                 }],
                 "key":
                 "% severely wasted (severe acute malnutrition)"
             }],
             "all_locations": [
                 {
                     "loc_name": "st2",
                     "percent": 16.666666666666668,
                 },
                 {
                     "loc_name": "st1",
                     "percent": 57.142857142857146
                 },
             ]
         })
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_severe_data_chart('icds-cas',
                                             config={
                                                 'month': (2017, 5, 1),
                                                 'aggregation_level': 1
                                             },
                                             loc_level='state'),
         {
             "location_type":
             "State",
             "bottom_five": [{
                 "loc_name": "st1",
                 "percent": 0.8810572687224669
             }, {
                 "loc_name": "st2",
                 "percent": 1.2072434607645874
             }],
             "top_five": [{
                 "loc_name": "st1",
                 "percent": 0.8810572687224669
             }, {
                 "loc_name": "st2",
                 "percent": 1.2072434607645874
             }],
             "chart_data": [{
                 "color":
                 "#fee0d2",
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.0061162079510703364,
                     "x": 1491004800000,
                     "all": 981
                 }, {
                     "y": 0.022082018927444796,
                     "x": 1493596800000,
                     "all": 951
                 }],
                 "key":
                 "% normal"
             }, {
                 "color":
                 "#fc9272",
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.0010193679918450561,
                     "x": 1491004800000,
                     "all": 981
                 }, {
                     "y": 0.008412197686645636,
                     "x": 1493596800000,
                     "all": 951
                 }],
                 "key":
                 "% moderately wasted (moderate acute malnutrition)"
             }, {
                 "color":
                 "#de2d26",
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.0020387359836901123,
                     "x": 1491004800000,
                     "all": 981
                 }, {
                     "y": 0.002103049421661409,
                     "x": 1493596800000,
                     "all": 951
                 }],
                 "key":
                 "% severely wasted (severe acute malnutrition)"
             }],
             "all_locations": [{
                 "loc_name": "st1",
                 "percent": 0.8810572687224669
             }, {
                 "loc_name": "st2",
                 "percent": 1.2072434607645874
             }]
         })
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_severe_data_chart(
             'icds-cas',
             config={
                 'month': (2017, 5, 1),
                 'aggregation_level': 1
             },
             loc_level='state'
         ),
         {
             "location_type": "State",
             "bottom_five": [
                 {
                     "loc_name": "st1",
                     "percent": 0.89086859688196
                 },
                 {
                     "loc_name": "st2",
                     "percent": 1.2244897959183674
                 }
             ],
             "top_five": [
                 {
                     "loc_name": "st1",
                     "percent": 0.89086859688196
                 },
                 {
                     "loc_name": "st2",
                     "percent": 1.2244897959183674
                 }
             ],
             "chart_data": [
                 {
                     "color": ChartColors.PINK,
                     "classed": "dashed",
                     "strokeWidth": 2,
                     "values": [
                         {
                             "y": 0.0,
                             "x": 1485907200000,
                             "all": 0
                         },
                         {
                             "y": 0.0,
                             "x": 1488326400000,
                             "all": 0
                         },
                         {
                             "y": 0.006224066390041493,
                             "x": 1491004800000,
                             "all": 964
                         },
                         {
                             "y": 0.022364217252396165,
                             "x": 1493596800000,
                             "all": 939
                         }
                     ],
                     "key": "% normal"
                 },
                 {
                     "color": ChartColors.ORANGE,
                     "classed": "dashed",
                     "strokeWidth": 2,
                     "values": [
                         {
                             "y": 0.0,
                             "x": 1485907200000,
                             "all": 0
                         },
                         {
                             "y": 0.0,
                             "x": 1488326400000,
                             "all": 0
                         },
                         {
                             "y": 0.001037344398340249,
                             "x": 1491004800000,
                             "all": 964
                         },
                         {
                             "y": 0.008519701810436636,
                             "x": 1493596800000,
                             "all": 939
                         }
                     ],
                     "key": "% moderately wasted (moderate acute malnutrition)"
                 },
                 {
                     "color": ChartColors.RED,
                     "classed": "dashed",
                     "strokeWidth": 2,
                     "values": [
                         {
                             "y": 0.0,
                             "x": 1485907200000,
                             "all": 0
                         },
                         {
                             "y": 0.0,
                             "x": 1488326400000,
                             "all": 0
                         },
                         {
                             "y": 0.002074688796680498,
                             "x": 1491004800000,
                             "all": 964
                         },
                         {
                             "y": 0.002129925452609159,
                             "x": 1493596800000,
                             "all": 939
                         }
                     ],
                     "key": "% severely wasted (severe acute malnutrition)"
                 }
             ],
             "all_locations": [
                 {
                     "loc_name": "st1",
                     "percent": 0.89086859688196
                 },
                 {
                     "loc_name": "st2",
                     "percent": 1.2244897959183674
                 }
             ]
         }
     )