def test_points(self): # test that the total score for all of the components is correct facility = Facility.objects.create() facility_data = [ ('net_intake_rate', 0.97), # 5 points ('distance_from_catchment_area', 1.5), # 2 points ('distance_to_nearest_secondary_school', 0.5), # 2 points ('proportion_of_students_living_less_than_3km_away', 0.4), # 1 point ('net_enrollment_ratio', 0.75), # 2 points ('female_to_male_ratio', 0.9), # 2 points ] # total: 14 points for slug, value in facility_data: facility.set(self.variables[slug], value) access = get_education_access_and_participation_score_variable() self.maxDiff = None self.assertEquals(access.score_dict(facility), { 'net_intake_rate': 5, 'distance_from_catchment_area': 2, 'distance_to_nearest_secondary_school': 2, 'proportion_of_students_living_less_than_3km_away': 1, 'net_enrollment_ratio': 2, 'female_to_male_ratio': 2, }) self.assertEquals(access.score(facility), 14.0) # test that the maximum achievable score is correct self.assertEquals(access.maximum_score(facility), 22.0)
def test_distance_component(self): # make sure the weight calculated from the distance for the # school is correct facility = Facility.objects.create() self.distance = self.variables['distance_from_catchment_area'] facility.set(self.distance, 1.5) # 2 points access = get_education_access_and_participation_score_variable()