def test_data_AWCs_reported_clean_drinking_water(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][0][0], { "redirect": "clean_water", "all": 30, "format": "percent_and_div", "color": "red", "percent": -3.3333333333333286, "value": 29, "label": "AWCs Reported Clean Drinking Water", "frequency": "month", "help_text": "Of the AWCs that have submitted an Infrastructure Details form, " "the percentage of AWCs that reported having a source of clean drinking water. " })
def test_data_AWCs_reported_medicine_kit(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][2][0], { "redirect": "medicine_kit", "all": 30, "format": "percent_and_div", "color": "red", "percent": -15.151515151515161, "value": 20, "label": "AWCs Reported Medicine Kit", "frequency": "month", "help_text": "Of the AWCs that have submitted an Infrastructure Details form, " "the percentage of AWCs that reported having a Medicine Kit" })
def get_program_summary_data(step, domain, config, now, include_test, pre_release_features): data = {} retry = 0 while True: config_copy = deepcopy(config) if step == 'maternal_child': data = get_maternal_child_data(domain, config_copy, include_test, pre_release_features) elif step == 'icds_cas_reach': data = get_cas_reach_data( domain, now, config_copy, include_test, ) elif step == 'demographics': data = get_demographics_data(domain, now, config_copy, include_test, beta=pre_release_features) elif step == 'awc_infrastructure': data = get_awc_infrastructure_data(domain, config_copy, include_test) if not _all_zeros(data) or retry == 2: break else: sleep(5) retry += 1 return data
def test_data_AWCs_reported_weighing_scale_mother_and_child(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][1][1], { "redirect": "awc_infrastructure/adult_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 40.00000000000001, "value": 9, "label": "AWCs Reported Weighing Scale: Mother and Child", "frequency": "month", "help_text": awcs_reported_weighing_scale_mother_and_child_help_text() })
def test_data_AWCs_reported_weighing_scale_infants(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][1][0], { "redirect": "infants_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 11.999999999999998, "value": 24, "label": "AWCs Reported Weighing Scale: Infants", "frequency": "month", "help_text": "Percentage of AWCs that reported having a weighing scale for infants" })
def test_data_AWCs_reported_weighing_scale_mother_and_child(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][1][1], { "redirect": "adult_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 40.00000000000001, "value": 9, "label": "AWCs Reported Weighing Scale: Mother and Child", "frequency": "month", "help_text": "Of the AWCs that have submitted an Infrastructure Details form, " "the percentage of AWCs that reported having a weighing scale for mother and child" })
def test_data_AWCs_reported_functional_toilet(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][0][1], { "redirect": "functional_toilet", "all": 30, "format": "percent_and_div", "color": "red", "percent": -12.499999999999995, "value": 15, "label": "AWCs Reported Functional Toilet", "frequency": "month", "help_text": "Of the AWCs that submitted an Infrastructure Details form, " "the percentage of AWCs that reported having a functional toilet" })
def test_data_records_length(self): self.assertEqual( len( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records']), 3)
def test_data_records_total_length(self): data = get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'] self.assertEqual(sum([len(record_row) for record_row in data]), 5)
def test_data_keys(self): self.assertEqual( list( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 }).keys()), ['records'])
def get_program_summary_data(step, domain, config, now, include_test, pre_release_features): data = {} if step == 'maternal_child': data = get_maternal_child_data(domain, config, include_test, pre_release_features) elif step == 'icds_cas_reach': data = get_cas_reach_data(domain, now, config, include_test) elif step == 'demographics': data = get_demographics_data(domain, now, config, include_test, beta=pre_release_features) elif step == 'awc_infrastructure': data = get_awc_infrastructure_data(domain, config, include_test) return data
def test_data_keys(self): self.assertEqual( list(get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } ).keys()), ['records'] )
def test_data_records_length(self): self.assertEqual( len(get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records']), 3 )
def test_data_records_total_length(self): data = get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'] self.assertEqual( sum([len(record_row) for record_row in data]), 5 )
def test_data_AWCs_reported_medicine_kit(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][2][0], { "redirect": "awc_infrastructure/medicine_kit", "all": 30, "format": "percent_and_div", "color": "red", "percent": -15.151515151515161, "value": 20, "label": "AWCs Reported Medicine Kit", "frequency": "month", "help_text": awcs_reported_medicine_kit_help_text() })
def test_data_AWCs_reported_functional_toilet(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][0][1], { "redirect": "awc_infrastructure/functional_toilet", "all": 30, "format": "percent_and_div", "color": "red", "percent": -12.499999999999995, "value": 15, "label": "AWCs Reported Functional Toilet", "frequency": "month", "help_text": awcs_reported_functional_toilet_help_text() })
def test_data_AWCs_reported_clean_drinking_water(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 })['records'][0][0], { "redirect": "awc_infrastructure/clean_water", "all": 30, "format": "percent_and_div", "color": "red", "percent": -3.3333333333333286, "value": 29, "label": "AWCs Reported Clean Drinking Water", "frequency": "month", "help_text": awcs_reported_clean_drinking_water_help_text() })
def test_data_AWCs_reported_clean_drinking_water(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'][0][0], { "redirect": "awc_infrastructure/clean_water", "all": 30, "format": "percent_and_div", "color": "red", "percent": -3.3333333333333286, "value": 29, "label": "AWCs Reported Clean Drinking Water", "frequency": "month", "help_text": awcs_reported_clean_drinking_water_help_text() } )
def test_data_AWCs_reported_functional_toilet(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'][0][1], { "redirect": "awc_infrastructure/functional_toilet", "all": 30, "format": "percent_and_div", "color": "red", "percent": -12.499999999999995, "value": 15, "label": "AWCs Reported Functional Toilet", "frequency": "month", "help_text": awcs_reported_functional_toilet_help_text() } )
def test_data_AWCs_reported_weighing_scale_infants(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'][1][0], { "redirect": "awc_infrastructure/infants_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 11.999999999999998, "value": 24, "label": "AWCs Reported Weighing Scale: Infants", "frequency": "month", "help_text": awcs_reported_weighing_scale_infants_help_text() } )
def test_data_AWCs_reported_weighing_scale_mother_and_child(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'][1][1], { "redirect": "awc_infrastructure/adult_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 40.00000000000001, "value": 9, "label": "AWCs Reported Weighing Scale: Mother and Child", "frequency": "month", "help_text": awcs_reported_weighing_scale_mother_and_child_help_text() } )
def test_data_AWCs_reported_medicine_kit(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 } )['records'][2][0], { "redirect": "awc_infrastructure/medicine_kit", "all": 30, "format": "percent_and_div", "color": "red", "percent": -15.151515151515161, "value": 20, "label": "AWCs Reported Medicine Kit", "frequency": "month", "help_text": awcs_reported_medicine_kit_help_text() } )
def test_data(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 }), { "records": [[{ "redirect": "clean_water", "all": 30, "format": "percent_and_div", "color": "red", "percent": -3.3333333333333286, "value": 29, "label": "AWCs Reported Clean Drinking Water", "frequency": "month", "help_text": "Percentage of AWCs that reported having a source of clean drinking water" }, { "redirect": "functional_toilet", "all": 30, "format": "percent_and_div", "color": "red", "percent": -12.499999999999995, "value": 15, "label": "AWCs Reported Functional Toilet", "frequency": "month", "help_text": "Percentage of AWCs that reported having a functional toilet" }], [{ "redirect": "infants_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 11.999999999999996, "value": 24, "label": "AWCs Reported Weighing Scale: Infants", "frequency": "month", "help_text": "Percentage of AWCs that reported having a weighing scale for infants" }, { "redirect": "adult_weight_scale", "all": 30, "format": "percent_and_div", "color": "green", "percent": 40.00000000000001, "value": 9, "label": "AWCs Reported Weighing Scale: Mother and Child", "frequency": "month", "help_text": "Percentage of AWCs that reported having" " a weighing scale for mother and child" }], [{ "redirect": "medicine_kit", "all": 30, "format": "percent_and_div", "color": "red", "percent": -15.15151515151516, "value": 20, "label": "AWCs Reported Medicine Kit", "frequency": "month", "help_text": "Percentage of AWCs that reported having a Medicine Kit" }]] })
def test_data(self): self.assertDictEqual( get_awc_infrastructure_data( 'icds-cas', { 'month': (2017, 5, 1), 'prev_month': (2017, 4, 1), 'aggregation_level': 1 }), { "records": [[{ "redirect": "clean_water", "color": "green", "all": 50, "frequency": "month", "format": "percent_and_div", "help_text": "Percentage of AWCs with a source of clean drinking water", "percent": 107.1428571428571, "value": 29, "label": "AWCs with Clean Drinking Water" }, { "redirect": "functional_toilet", "color": "green", "all": 50, "frequency": "month", "format": "percent_and_div", "help_text": "AWCs with functional toilet", "percent": 87.5, "value": 15, "label": "AWCs with Functional Toilet" }], [{ "redirect": "infants_weight_scale", "color": "green", "all": 50, "frequency": "month", "format": "percent_and_div", "help_text": "Percentage of AWCs with weighing scale for infants", "percent": 140.0, "value": 24, "label": "AWCs with Weighing Scale: Infants" }, { "redirect": "adult_weight_scale", "color": "green", "all": 50, "frequency": "month", "format": "percent_and_div", "help_text": "Percentage of AWCs with weighing scale for mother and child", "percent": 200.0, "value": 9, "label": "AWCs with Weighing Scale: Mother and Child" }], [{ "redirect": "medicine_kit", "color": "green", "all": 50, "frequency": "month", "format": "percent_and_div", "help_text": "Percentage of AWCs with a Medicine Kit", "percent": 81.81818181818183, "value": 20, "label": "AWCs with Medicine Kit" }]] })