def test_duplicate(self): """ check the admitted and wait_listed have no duplicate ids """ admitted, wait_listed = get(self.applicants) check = True for admit in admitted: for wait in wait_listed: if admit.get("application_id") is wait.get("application_id"): check = False self.assertTrue(check)
def test_alumni_affirmative(self): """ check the admitted's first 6 applicant has alumni parent and 7~9 have affirmative action """ admitted, _ = get(self.applicants) check = True for index in range(6): if not admitted[index].get("has_alumni_parent"): check = False for index in range(3): if not admitted[index+6].get("affirmative_action"): check = False self.assertTrue(check)
def print_list(self): """ Print admitted and waitlisted candidate details. """ applications = Applications(1000) admitted = get(applications) admitted_applicants = admitted[0] waitlisted_applicants = admitted[1] print("------------Admitted Applicants-----------------") for index, applicant in enumerate(admitted_applicants): print("%10d%22d" %(index + 1,applicant["application_id"])) print("-----------Waitlisted Applicants----------------") for index, applicant in enumerate(waitlisted_applicants): print("%10d%22d" %(index + 1,applicant["application_id"]))
class Run(object): """ Invoking the admissions logic. """ random.seed(0) applicants = Applications(1000) applicants_list, admitted, wait_listed = [], [], [] for apply in applicants: applicants_list.append(apply) admitted, wait_listed = admissions.get(applicants_list) def print_list(self): """ Print admitted and waitlisted candidate details. """ sort_admitted = sorted(self.admitted, key=lambda x: x.get("application_id")) sort_waited = sorted(self.wait_listed, key=lambda x: x.get("application_id")) for index, applicant in enumerate(sort_admitted): print(index + 1, applicant.get("application_id")) for index, applicant in enumerate(sort_waited): print(index + 1, applicant.get("application_id"))
def setUp(self): applications = Applications(1000) self.apps =get(applications)