def test_chart_data_all_locations(self): data = get_prevalence_of_stunting_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': 56.0 }, { 'loc_name': 'st1', 'percent': 71.42857142857143 }])
def test_chart_data_location_type(self): data = get_prevalence_of_stunting_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_stunting_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_stunting_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_location_type(self): data = get_prevalence_of_stunting_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_all_locations(self): data = get_prevalence_of_stunting_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['all_locations'], [ { "loc_name": "st2", "percent": 56.0 }, { "loc_name": "st1", "percent": 71.42857142857143 }, ])
def test_chart_data_top_five(self): data = get_prevalence_of_stunting_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state') self.assertListEqual(data['top_five'], [ { "loc_name": "st1", "percent": 0.0 }, { "loc_name": "st2", "percent": 0.0 }, ])
def test_chart_data_red_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_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'][2], { "color": ChartColors.RED, "classed": "dashed", "strokeWidth": 2, "values": [ { "y": 0.0, "x": 1485907200000, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1491004800000, "all": 981, "measured": 1 }, { "y": 0.0, "x": 1493596800000, "all": 951, "measured": 0 } ], "key": "% severely stunted" } )
def test_chart_data_pink(self): data = get_prevalence_of_stunting_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, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.3076923076923077, "x": 1491004800000, "all": 981, "measured": 13 }, { "y": 0.40625, "x": 1493596800000, "all": 952, "measured": 32 } ], "key": "% normal" } )
def test_chart_data_red(self): data = get_prevalence_of_stunting_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, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.38461538461538464, "x": 1491004800000, "all": 981, "measured": 13 }, { "y": 0.34375, "x": 1493596800000, "all": 952, "measured": 32 } ], "key": "% severely stunted" } )
def test_chart_data_orange(self): data = get_prevalence_of_stunting_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, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1491004800000, "all": 964, "measured": 0 }, { "y": 0.0, "x": 1493596800000, "all": 939, "measured": 0 } ], "key": "% moderately stunted" } )
def test_chart_data_pink(self): data = get_prevalence_of_stunting_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, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.3076923076923077, "x": 1491004800000, "all": 980, "measured": 13 }, { "y": 0.40625, "x": 1493596800000, "all": 951, "measured": 32 } ], "key": "% normal" } )
def test_chart_data_all_locations_icds_feature_flag_enabled(self): data = get_prevalence_of_stunting_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": 0.0 }, ])
def test_chart_data_top_five(self): data = get_prevalence_of_stunting_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_all_locations(self): data = get_prevalence_of_stunting_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': 56.0}, {'loc_name': 'st1', 'percent': 71.42857142857143} ] )
def test_chart_data_red(self): data = get_prevalence_of_stunting_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, "all": 0, "measured": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0, "measured": 0 }, { "y": 0.4166666666666667, "x": 1491004800000, "all": 1021, "measured": 12 }, { "y": 0.34375, "x": 1493596800000, "all": 989, "measured": 32 }], "key": "% severely stunted" })
def test_chart_data(self): self.assertDictEqual( get_prevalence_of_stunting_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "location_type": "State", "bottom_five": [{ "loc_name": "st1", "percent": 1.78173719376392 }, { "loc_name": "st2", "percent": 3.673469387755102 }], "top_five": [{ "loc_name": "st1", "percent": 1.78173719376392 }, { "loc_name": "st2", "percent": 3.673469387755102 }], "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.0031120331950207467, "x": 1491004800000, "all": 964 }, { "y": 0.01597444089456869, "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.004149377593360996, "x": 1491004800000, "all": 964 }, { "y": 0.010649627263045794, "x": 1493596800000, "all": 939 }], "key": "% moderately stunted" }, { "color": ChartColors.RED, "classed": "dashed", "strokeWidth": 2, "values": [{ "y": 0.0, "x": 1485907200000, "all": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0 }, { "y": 0.008298755186721992, "x": 1491004800000, "all": 964 }, { "y": 0.01703940362087327, "x": 1493596800000, "all": 939 }], "key": "% severely stunted" }], "all_locations": [{ "loc_name": "st1", "percent": 1.78173719376392 }, { "loc_name": "st2", "percent": 3.673469387755102 }] })
def test_chart_data(self): self.assertDictEqual( get_prevalence_of_stunting_data_chart('icds-cas', config={ 'month': (2017, 5, 1), 'aggregation_level': 1 }, loc_level='state'), { "location_type": "State", "bottom_five": [ { "loc_name": "st2", "percent": 56.0 }, { "loc_name": "st1", "percent": 71.42857142857143 }, ], "top_five": [ { "loc_name": "st2", "percent": 56.0 }, { "loc_name": "st1", "percent": 71.42857142857143 }, ], "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.18181818181818182, "x": 1491004800000, "all": 11 }, { "y": 0.40625, "x": 1493596800000, "all": 32 }], "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.36363636363636365, "x": 1491004800000, "all": 11 }, { "y": 0.25, "x": 1493596800000, "all": 32 }], "key": "% moderately stunted" }, { "color": ChartColors.RED, "classed": "dashed", "strokeWidth": 2, "values": [{ "y": 0.0, "x": 1485907200000, "all": 0 }, { "y": 0.0, "x": 1488326400000, "all": 0 }, { "y": 0.45454545454545453, "x": 1491004800000, "all": 11 }, { "y": 0.34375, "x": 1493596800000, "all": 32 }], "key": "% severely stunted" }], "all_locations": [ { "loc_name": "st2", "percent": 56.0 }, { "loc_name": "st1", "percent": 71.42857142857143 }, ] })