def test_chart_data(self): self.assertDictEqual( get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "location_type": "State", "bottom_five": [{ "loc_name": "st1", "percent": 50.0 }, { "loc_name": "st2", "percent": 45.833333333333336 }], "top_five": [{ "loc_name": "st1", "percent": 50.0 }, { "loc_name": "st2", "percent": 45.833333333333336 }], "chart_data": [{ "color": "#006fdf", "classed": "dashed", "strokeWidth": 2, "values": [{ "y": 0.0, "x": 1485907200000, "in_month": 0 }, { "y": 0.0, "x": 1488326400000, "in_month": 0 }, { "y": 0.2, "x": 1491004800000, "in_month": 10 }, { "y": 0.48, "x": 1493596800000, "in_month": 24 }], "key": "% of AWCs with a weighing scale for infants." }], "all_locations": [{ "loc_name": "st1", "percent": 50.0 }, { "loc_name": "st2", "percent": 45.833333333333336 }] })
def test_chart_data(self): self.assertDictEqual( get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "location_type": "State", "bottom_five": [{ "loc_name": "st1", "percent": 1300.0 }, { "loc_name": "st2", "percent": 1100.0 }], "top_five": [{ "loc_name": "st1", "percent": 1300.0 }, { "loc_name": "st2", "percent": 1100.0 }], "chart_data": [{ "color": ChartColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [{ "y": 0.0, "x": 1485907200000, "in_month": 0 }, { "y": 0.0, "x": 1488326400000, "in_month": 0 }, { "y": 5.0, "x": 1491004800000, "in_month": 10 }, { "y": 12.0, "x": 1493596800000, "in_month": 24 }], "key": "Percentage of AWCs that reported having a weighing scale for infants" }], "all_locations": [{ "loc_name": "st1", "percent": 1300.0 }, { "loc_name": "st2", "percent": 1100.0 }] })
def test_chart_data(self): data = get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['chart_data'], [{ "color": ChartColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [{ "y": 0.0, "x": 1485907200000, "in_month": 0 }, { "y": 0.0, "x": 1488326400000, "in_month": 0 }, { "y": 0.7142857142857143, "x": 1491004800000, "in_month": 10 }, { "y": 0.8, "x": 1493596800000, "in_month": 24 }], "key": "Percentage of AWCs that reported having a weighing scale for infants" }])
def test_chart_data_bottom_five_locations(self): data = get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['bottom_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_locations(self): data = get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['top_five'], [ { "loc_name": "st2", "percent": 84.61538461538461 }, { "loc_name": "st1", "percent": 76.47058823529412 }, { 'loc_name': 'st3', 'percent': 0.0 }, { 'loc_name': 'st4', 'percent': 0.0 }, { 'loc_name': 'st5', 'percent': 0.0 }, ])
def test_chart_data_location_type(self): data = get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(data['location_type'], "State")
def test_chart_data_location_type(self): data = get_infants_weight_scale_data_chart( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(data['location_type'], "State")
def test_chart_data_keys(self): data = get_infants_weight_scale_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertEquals(len(data), 5) self.assertIn('top_five', data) self.assertIn('bottom_five', data) self.assertIn('all_locations', data) self.assertIn('chart_data', data) self.assertIn('location_type', data)
def test_chart_data_keys(self): data = get_infants_weight_scale_data_chart( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertEquals(len(data), 5) self.assertIn('top_five', data) self.assertIn('bottom_five', data) self.assertIn('all_locations', data) self.assertIn('chart_data', data) self.assertIn('location_type', data)
def test_chart_data_bottom_five_locations(self): data = get_infants_weight_scale_data_chart( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['bottom_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_locations(self): data = get_infants_weight_scale_data_chart( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['top_five'], [ {"loc_name": "st2", "percent": 84.61538461538461}, {"loc_name": "st1", "percent": 76.47058823529412}, {'loc_name': 'st4', 'percent': 0.0}, {'loc_name': 'st5', 'percent': 0.0}, {'loc_name': 'st6', 'percent': 0.0} ] )
def test_chart_data(self): data = get_infants_weight_scale_data_chart( 'icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state' ) self.assertListEqual( data['chart_data'], [ { "color": ChartColors.BLUE, "classed": "dashed", "strokeWidth": 2, "values": [ { "y": 0.0, "x": 1485907200000, "in_month": 0 }, { "y": 0.0, "x": 1488326400000, "in_month": 0 }, { "y": 0.7142857142857143, "x": 1491004800000, "in_month": 10 }, { "y": 0.8, "x": 1493596800000, "in_month": 24 } ], "key": "Percentage of AWCs that reported having a weighing scale for infants" } ] )