Esempio n. 1
0
 def test_chart_data_all_locations(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 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.58047493403694
                          }, {
                              'loc_name': 'st1',
                              'percent': 22.71293375394322
                          }])
Esempio n. 2
0
 def test_chart_data_pink(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertDictEqual(
         data['chart_data'][0], {
             "color":
             ChartColors.PINK,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.7478260869565218,
                 "x": 1491004800000,
                 "weighed": 3450,
                 "unweighed": 1655
             }, {
                 "y": 0.7856115107913669,
                 "x": 1493596800000,
                 "weighed": 3475,
                 "unweighed": 1480
             }],
             "key":
             "% Normal"
         })
Esempio n. 3
0
 def test_chart_data_top_five(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 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_orange(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertDictEqual(
         data['chart_data'][1], {
             "color":
             ChartColors.ORANGE,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.23154848046309695,
                 "x": 1491004800000,
                 "weighed": 3455,
                 "unweighed": 1655
             }, {
                 "y": 0.1867816091954023,
                 "x": 1493596800000,
                 "weighed": 3480,
                 "unweighed": 1465
             }],
             "key":
             "% Moderately Underweight (-2 SD)"
         })
 def test_chart_data_pink(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertDictEqual(
         data['chart_data'][0], {
             "color":
             ChartColors.PINK,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.7467438494934877,
                 "x": 1491004800000,
                 "weighed": 3455,
                 "unweighed": 1655
             }, {
                 "y": 0.7844827586206896,
                 "x": 1493596800000,
                 "weighed": 3480,
                 "unweighed": 1465
             }],
             "key":
             "% Normal"
         })
 def test_chart_data_red(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertDictEqual(
         data['chart_data'][2], {
             "color":
             ChartColors.RED,
             "classed":
             "dashed",
             "strokeWidth":
             2,
             "values": [{
                 "y": 0.0,
                 "x": 1485907200000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.02170767004341534,
                 "x": 1491004800000,
                 "weighed": 3455,
                 "unweighed": 1655
             }, {
                 "y": 0.028735632183908046,
                 "x": 1493596800000,
                 "weighed": 3480,
                 "unweighed": 1465
             }],
             "key":
             "% Severely Underweight (-3 SD) "
         })
 def test_chart_data_location_type(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertEquals(data['location_type'], 'State')
 def test_chart_data_elements_length(self):
     data = get_prevalence_of_undernutrition_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_elements_length(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertEquals(len(data['chart_data']), 3)
    def test_chart_data_location_type(self):

        data = get_prevalence_of_undernutrition_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_keys_length(self):
     self.maxDiff = None
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state')
     self.assertEqual(len(data), 5)
 def test_chart_data_all_locations(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertListEqual(data['all_locations'], [
         {
             "loc_name": "st2",
             "percent": 20.58047493403694
         },
         {
             "loc_name": "st1",
             "percent": 22.71293375394322
         },
     ])
 def test_chart_data_bottom_five(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['bottom_five'],
         [
             {'loc_name': 'st6', 'percent': 0.0},
             {'loc_name': 'st7', 'percent': 0.0},
             {'loc_name': 'st3', 'percent': 0.0},
             {'loc_name': 'st2', 'percent': 20.58047493403694},
             {'loc_name': 'st1', 'percent': 22.71293375394322}
         ]
     )
 def test_chart_data_top_five(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertListEqual(
         data['top_five'],
         [
             {'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': 'st3', 'percent': 0.0}
         ]
     )
 def test_chart_data_top_five(self):
     self.maxDiff = None
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state')
     self.assertListEqual(data['top_five'], [{
         'loc_name': 'st7',
         'percent': 0.0
     }, {
         'loc_name': 'st2',
         'percent': 20.37037037037037
     }, {
         'loc_name': 'st1',
         'percent': 22.71293375394322
     }])
Esempio n. 16
0
 def test_chart_data_bottom_five(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertListEqual(data['bottom_five'], [{
         'loc_name': 'st5',
         'percent': 0.0
     }, {
         'loc_name': 'st6',
         'percent': 0.0
     }, {
         'loc_name': 'st7',
         'percent': 0.0
     }, {
         'loc_name': 'st2',
         'percent': 20.37037037037037
     }, {
         'loc_name': 'st1',
         'percent': 22.71293375394322
     }])
 def test_chart_data_red(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertDictEqual(
         data['chart_data'][2],
         {
             "color": ChartColors.RED,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.02170767004341534,
                     "x": 1491004800000,
                     "weighed": 3455,
                     "unweighed": 1655
                 },
                 {
                     "y": 0.028735632183908046,
                     "x": 1493596800000,
                     "weighed": 3480,
                     "unweighed": 1480
                 }
             ],
             "key": "% Severely Underweight (-3 SD) "
         }
     )
 def test_chart_data_orange(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertDictEqual(
         data['chart_data'][1],
         {
             "color": ChartColors.ORANGE,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.23154848046309695,
                     "x": 1491004800000,
                     "weighed": 3455,
                     "unweighed": 1655
                 },
                 {
                     "y": 0.1867816091954023,
                     "x": 1493596800000,
                     "weighed": 3480,
                     "unweighed": 1480
                 }
             ],
             "key": "% Moderately Underweight (-2 SD)"
         }
     )
 def test_chart_data_pink(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas',
         config={
             'month': (2017, 5, 1)
         },
         loc_level='state'
     )
     self.assertDictEqual(
         data['chart_data'][0],
         {
             "color": ChartColors.PINK,
             "classed": "dashed",
             "strokeWidth": 2,
             "values": [
                 {
                     "y": 0.0,
                     "x": 1485907200000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.0,
                     "x": 1488326400000,
                     "weighed": 0,
                     "unweighed": 0
                 },
                 {
                     "y": 0.7467438494934877,
                     "x": 1491004800000,
                     "weighed": 3455,
                     "unweighed": 1655
                 },
                 {
                     "y": 0.7844827586206896,
                     "x": 1493596800000,
                     "weighed": 3480,
                     "unweighed": 1480
                 }
             ],
             "key": "% Normal"
         }
     )
 def test_chart_data_orange(self):
     self.maxDiff = None
     data = get_prevalence_of_undernutrition_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,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.23043478260869565,
                 "x": 1491004800000,
                 "weighed": 690,
                 "unweighed": 331
             }, {
                 "y": 0.1856115107913669,
                 "x": 1493596800000,
                 "weighed": 695,
                 "unweighed": 294
             }],
             "key":
             "% Moderately Underweight (-2 SD)"
         })
 def test_chart_data_red(self):
     self.maxDiff = None
     data = get_prevalence_of_undernutrition_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,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.0,
                 "x": 1488326400000,
                 "weighed": 0,
                 "unweighed": 0
             }, {
                 "y": 0.021739130434782608,
                 "x": 1491004800000,
                 "weighed": 690,
                 "unweighed": 331
             }, {
                 "y": 0.02877697841726619,
                 "x": 1493596800000,
                 "weighed": 695,
                 "unweighed": 294
             }],
             "key":
             "% Severely Underweight (-3 SD) "
         })
Esempio n. 22
0
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_undernutrition_data_chart(
             'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state'),
         {
             "location_type":
             "State",
             "bottom_five": [
                 {
                     "loc_name": "st1",
                     "percent": 15.157894736842104
                 },
                 {
                     "loc_name": "st2",
                     "percent": 15.17509727626459
                 },
             ],
             "top_five": [
                 {
                     "loc_name": "st1",
                     "percent": 15.157894736842104
                 },
                 {
                     "loc_name": "st2",
                     "percent": 15.17509727626459
                 },
             ],
             "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.5048923679060665,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.5520728008088979,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "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.15655577299412915,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.13144590495449948,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "key":
                 "% Moderately Underweight (-2 SD)"
             }, {
                 "color":
                 ChartColors.RED,
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.014677103718199608,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.020222446916076844,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "key":
                 "% Severely Underweight (-3 SD) "
             }],
             "all_locations": [
                 {
                     "loc_name": "st1",
                     "percent": 15.157894736842104
                 },
                 {
                     "loc_name": "st2",
                     "percent": 15.17509727626459
                 },
             ]
         })
 def test_chart_data_keys_length(self):
     data = get_prevalence_of_undernutrition_data_chart(
         'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state')
     self.assertEquals(len(data), 5)
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_undernutrition_data_chart(
             'icds-cas',
             config={
                 'month': (2017, 5, 1)
             },
             loc_level='state'
         ),
         {
             "location_type": "State",
             "bottom_five": [
                 {
                     "loc_name": "st2",
                     "percent": 14.648729446935725
                 },
                 {
                     "loc_name": "st1",
                     "percent": 15.857605177993527
                 }
             ],
             "top_five": [
                 {
                     "loc_name": "st2",
                     "percent": 14.648729446935725
                 },
                 {
                     "loc_name": "st1",
                     "percent": 15.857605177993527
                 }
             ],
             "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.4976228209191759,
                             "x": 1491004800000,
                             "all": 6310
                         },
                         {
                             "y": 0.5897435897435898,
                             "x": 1493596800000,
                             "all": 6435
                         }
                     ],
                     "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.1434231378763867,
                             "x": 1491004800000,
                             "all": 6310
                         },
                         {
                             "y": 0.1351981351981352,
                             "x": 1493596800000,
                             "all": 6435
                         }
                     ],
                     "key": "% Moderately Underweight (-2 SD)"
                 },
                 {
                     "color": "#de2d26",
                     "classed": "dashed",
                     "strokeWidth": 2,
                     "values": [
                         {
                             "y": 0.0,
                             "x": 1485907200000,
                             "all": 0
                         },
                         {
                             "y": 0.0,
                             "x": 1488326400000,
                             "all": 0
                         },
                         {
                             "y": 0.011885895404120444,
                             "x": 1491004800000,
                             "all": 6310
                         },
                         {
                             "y": 0.017094017094017096,
                             "x": 1493596800000,
                             "all": 6435
                         }
                     ],
                     "key": "% Severely Underweight (-3 SD) "
                 }
             ],
             "all_locations": [
                 {
                     "loc_name": "st2",
                     "percent": 14.648729446935725
                 },
                 {
                     "loc_name": "st1",
                     "percent": 15.857605177993527
                 }
             ]
         }
     )
 def test_chart_data(self):
     self.assertDictEqual(
         get_prevalence_of_undernutrition_data_chart(
             'icds-cas', config={'month': (2017, 5, 1)}, loc_level='state'),
         {
             "location_type":
             "State",
             "bottom_five": [{
                 "loc_name": "st2",
                 "percent": 19.06614785992218
             }, {
                 "loc_name": "st1",
                 "percent": 20.63157894736842
             }],
             "top_five": [{
                 "loc_name": "st2",
                 "percent": 19.06614785992218
             }, {
                 "loc_name": "st1",
                 "percent": 20.63157894736842
             }],
             "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.6144814090019569,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.7674418604651163,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "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.1771037181996086,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.17593528816986856,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "key":
                 "% Moderately Underweight (-2 SD)"
             }, {
                 "color":
                 ChartColors.RED,
                 "classed":
                 "dashed",
                 "strokeWidth":
                 2,
                 "values": [{
                     "y": 0.0,
                     "x": 1485907200000,
                     "all": 0
                 }, {
                     "y": 0.0,
                     "x": 1488326400000,
                     "all": 0
                 }, {
                     "y": 0.014677103718199608,
                     "x": 1491004800000,
                     "all": 5110
                 }, {
                     "y": 0.022244691607684528,
                     "x": 1493596800000,
                     "all": 4945
                 }],
                 "key":
                 "% Severely Underweight (-3 SD) "
             }],
             "all_locations": [{
                 "loc_name": "st2",
                 "percent": 19.06614785992218
             }, {
                 "loc_name": "st1",
                 "percent": 20.63157894736842
             }]
         })