def test_search_departments_having_patients_with_a_given_name(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) department2 = Departments(2, "Zika", 3) department3 = Departments(3, "coma", 1) repo1.add_department(department1) repo1.add_department(department2) repo1.add_department(department3) repo2 = PatientRepository() patient1 = Patients("Alexandru", "Elena", 1991115, "flu") patient2 = Patients("Bexan", "Cmm", 2344509, "flu") patient3 = Patients("A", "A", 2000001, "flu") patient4 = Patients("Alexandru", "G", 3099809, "Zika") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo2.add_patient(patient4) repo1.add_patients_to_department(repo2, department1) repo1.add_patients_to_department(repo2, department2) repo1.add_patients_to_department(repo2, department3) l = repo1.search_departments_having_patients_with_a_given_name( "Alexandru") try: if l[0] == department1 and l[1] == department2: assert True except Exception: assert False
def search_departments_having_patients_with_a_certain_age(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) department2 = Departments(2, "Zika", 3) department3 = Departments(3, "coma", 1) repo1.add_department(department1) repo1.add_department(department2) repo1.add_department(department3) repo2 = PatientRepository() patient1 = Patients("A", "E", 1991115, "flu") patient2 = Patients("B", "C", 2344509, "flu") patient3 = Patients("A", "A", 2000001, "flu") patient4 = Patients("E", "G", 3099809, "Zika") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo2.add_patient(patient4) repo1.add_patients_to_department(repo2, department1) repo1.add_patients_to_department(repo2, department2) repo1.add_patients_to_department(repo2, department3) l = repo1.search_departments_having_patients_with_a_certain_age(30) try: if l[0] == department1 and l[1] == department2: assert True except Exception as ex: assert False
def test_sort_departments_and_patients_alphabetically(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) department2 = Departments(2, "Zika", 3) department3 = Departments(3, "coma", 1) repo1.add_department(department1) repo1.add_department(department2) repo1.add_department(department3) repo2 = PatientRepository() patient1 = Patients("A", "E", 1991115, "flu") patient2 = Patients("B", "C", 2344509, "flu") patient3 = Patients("A", "A", 2000001, "flu") patient4 = Patients("E", "G", 3099809, "Zika") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo2.add_patient(patient4) repo1.add_patients_to_department(repo2, department1) repo1.add_patients_to_department(repo2, department2) repo1.add_patients_to_department(repo2, department3) repo1.sort_patients_from_department_by_age(15) try: l = department1.get_patients().get_all() if l[0] == patient3 and l[1] == patient1 and l[2] == patient2: assert True except Exception as ex: assert False
def test_sort_departments_by_number_of_patients(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) department2 = Departments(2, "Zika", 3) department3 = Departments(3, "coma", 1) repo1.add_department(department1) repo1.add_department(department2) repo1.add_department(department3) repo2 = PatientRepository() patient1 = Patients("A", "B", 111, "flu") patient2 = Patients("B", "C", 234, "flu") patient3 = Patients("C", "D", 2, "flu") patient4 = Patients("E", "G", 3, "Zika") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo2.add_patient(patient4) repo1.add_patients_to_department(repo2, department1) repo1.add_patients_to_department(repo2, department2) repo1.add_patients_to_department(repo2, department3) repo1.sort_departments_by_number_of_patients() try: l = repo1.get_all_departments() if l[0] == department3 and l[1] == department2 and l[ 2] == department1: assert True except Exception as ex: assert False
def test_add_patients_to_department(self): repo1 = PatientRepository() patient1 = Patients("G", "K", 111, "flu") patient2 = Patients("R", "R", 112, "coma") patient3 = Patients("A", "B", 1344, "flu") repo1.add_patient(patient1) repo1.add_patient(patient2) repo1.add_patient(patient3) department = Departments(1, "flu", 4) repo2 = DepartmentsRepository() repo2.add_department(department) repo2.add_patients_to_department(repo1, department) self.assertEqual(department.get_patients().get_size(), 2)
def test_get_patients_from_department(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) repo1.add_department(department1) repo2 = PatientRepository() patient1 = Patients("A", "B", 111, "flu") patient2 = Patients("B", "C", 234, "flu") patient3 = Patients("C", "D", 2, "flu") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo1.add_patients_to_department(repo2, department1) self.assertEqual( repo1.get_patients_from_department(department1).get_size(), 3)
def test_sort_patients_by_PNC(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) repo1.add_department(department1) repo2 = PatientRepository() patient1 = Patients("A", "B", 111, "flu") patient2 = Patients("B", "C", 234, "flu") patient3 = Patients("C", "D", 2, "flu") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo1.add_patients_to_department(repo2, department1) repo1.sort_patients_by_PNC(department1) try: l = department1.get_patients() if l.get_patient_by_index(0) == patient3 and l.get_patient_by_index( 1) == patient1 and l.get_patient_by_index(2) == patient2: assert True except Exception as ex: assert False
def test_back(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flu", 4) department2 = Departments(2, "Zika", 3) department3 = Departments(3, "coma", 1) repo1.add_department(department1) repo1.add_department(department2) repo1.add_department(department3) repo2 = PatientRepository() patient1 = Patients("A", "E", 1991115, "flu") patient2 = Patients("B", "C", 2344509, "flu") patient3 = Patients("A", "A", 2000001, "flu") patient4 = Patients("E", "G", 3099809, "Zika") patient5 = Patients("Chira", "Maira", 83284289, "flu") patient6 = Patients("Anca", "Grad", 1111111, "flu") patient7 = Patients("Lolea", "Oana", 2345678, "flu") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo1.add_patients_to_department(repo2, department1) repo1.add_patients_to_department(repo2, department2) repo1.add_patients_to_department(repo2, department3)
def test_get_a_certain_patient_from_department(self): repo1 = DepartmentsRepository() department1 = Departments(1, "flue", 4) repo1.add_department(department1) repo2 = PatientRepository() patient1 = Patients("A", "B", 111, "flu") patient2 = Patients("B", "C", 234, "flu") patient3 = Patients("C", "D", 2, "flu") patient4 = Patients("L", "K", 0, "Zika") repo2.add_patient(patient1) repo2.add_patient(patient2) repo2.add_patient(patient3) repo1.add_patients_to_department(repo2, department1) self.assertEqual( repo1.get_a_certain_patient_from_department_by_PNC( department1, patient4), "The patient does not exist") try: self.assertEqual( repo1.get_a_certain_patient_from_department_by_PNC( department1, patient1), patient4) assert False except Exception as ex: assert True