示例#1
0
 def test_get_patient_by_index(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     patient2 = Patients("L", "R", 2221, "Zika")
     patient3 = Patients("L", "P", 1209, "Yellow fever")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     self.assertEqual(repo.get_patient_by_index(0), patient1)
示例#2
0
 def test_delete_all_patients(self):
     repo = PatientRepository()
     patient1 = Patients("A", "AA", 111, "flu")
     patient2 = Patients("B", "BB", 124, "flu")
     patient3 = Patients("C", "L", 90, "Zika")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     repo.delete_all_patients()
     self.assertEqual(repo.get_size(), 0)
示例#3
0
 def test_get_size(self):
     repo1 = DepartmentsRepository()
     repo2 = PatientRepository()
     patient1 = Patients("G", "K", 111, "flu")
     patient2 = Patients("R", "R", 112, "coma")
     department1 = Departments(1, "flue", 4)
     repo2.add_patient(patient1)
     repo2.add_patient(patient2)
     department1.set_patients(repo2)
     repo1.add_department(department1)
     self.assertEqual(repo1.get_size_department(), 1)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 def test_get_patients_with_same_disease(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     patient2 = Patients("L", "R", 2221, "Zika")
     patient3 = Patients("L", "P", 1209, "Yellow fever")
     patient4 = Patients("A", "B", 10101, "flu")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     repo.add_patient(patient4)
     l = []
     l.append(patient1)
     l.append(patient4)
     self.assertEqual(repo.get_patients_with_the_same_disease("flu"), l)
示例#7
0
 def test_delete_patients_from_a_given_interval(self):
     repo = PatientRepository()
     patient1 = Patients("A", "AA", 111, "flu")
     patient2 = Patients("B", "BB", 124, "flu")
     patient3 = Patients("C", "L", 90, "Zika")
     patient4 = Patients("D", "C", 10101, "Denger fever")
     patient5 = Patients("E", "E", 9101, "Zika")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     repo.add_patient(patient4)
     repo.add_patient(patient5)
     repo.delete_patients_from_a_given_interval(1, 3)
     self.assertEqual(repo.get_size(), 2)
示例#8
0
 def test_delete_patients_with_a_given_disease(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     patient2 = Patients("L", "R", 2221, "Zika")
     patient3 = Patients("L", "P", 1209, "Yellow fever")
     patient4 = Patients("R", "TT", 362, "flu")
     patient5 = Patients("p", "ZZ", 1010, "flu")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     repo.add_patient(patient4)
     repo.add_patient(patient5)
     repo.delete_patients_with_a_given_disease("flu")
     self.assertEqual(repo.get_size(), 2)
示例#9
0
 def test_update_patient_by_PNC(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     patient2 = Patients("L", "R", 2221, "Zika")
     patient3 = Patients("L", "P", 1209, "Yellow fever")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     patient4 = Patients("K", "AA", 2221, "...")
     repo.update_patient_by_PNC(patient4, 2221)
     try:
         if patient1 == patient4:
             assert True
     except Exception as ex:
         assert False
示例#10
0
 def test_update_patients_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)
     repo2.delete_all_patients()
     repo2.add_patient(patient4)
     repo1.update_patients_from_department(department1, repo2)
     self.assertEqual(department1.get_patients().get_size(), 0)
示例#11
0
 def test_get_patient_by_name(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     patient2 = Patients("L", "R", 2221, "Zika")
     patient3 = Patients("L", "P", 1209, "Yellow fever")
     repo.add_patient(patient1)
     repo.add_patient(patient2)
     repo.add_patient(patient3)
     l = []
     l.append(patient3)
     self.assertEqual(repo.get_patient_by_name("L", "P"), l)
     try:
         self.assertEqual(repo.get_patient_by_name("A", "B"), patient2)
         assert False
     except Exception as ex:
         assert True
示例#12
0
 def test_update_department_by_index(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)
     department2 = Departments(2, "Zika", 3)
     patient4 = Patients("L", "M", 908, "Zika")
     repo2.add_patient(patient4)
     repo1.update_department_by_index(department2, 0)
     self.assertEqual(department1, department2)
示例#13
0
 def test_add_department(self):
     repo1 = DepartmentsRepository()
     repo2 = PatientRepository()
     patient1 = Patients("G", "K", 111, "flu")
     patient2 = Patients("R", "R", 112, "coma")
     department1 = Departments(1, "flue", 4)
     repo2.add_patient(patient1)
     repo2.add_patient(patient2)
     department1.set_patients(repo2)
     repo1.add_department(department1)
     department2 = Departments(1, "flu", 5)
     try:
         repo1.add_department(department2)
         assert False
     except Exception as ex:
         assert True
     self.assertEqual(repo1.get_size_department(), 1)
示例#14
0
 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
示例#15
0
 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
示例#16
0
 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)
from domain.business2 import Patients

p = Patients("", "", 0, "")


class PatientRepository:
    def __init__(self):
        self.__l = []

    def get_size(self):
        return len(self.__l)

    def get_all(self):
        return self.__l

    def add_patient(self, patient):
        for el in self.__l:
            if patient == el:
                raise ValueError("Patient already exists")
        self.__l.append(patient)

    def get_index(self, patient):
        if self.get_size() == 1:
            if self.__l[0] == patient:
                return 0
        else:
            for i in range(len(self.__l)):
                if patient == self.__l[i]:
                    return i
        return -1
示例#18
0
 def test_add_patient(self):
     repo = PatientRepository()
     patient1 = Patients("K", "J", 324, "flu")
     repo.add_patient(patient1)
     self.assertEqual(repo.get_size(), 1)
示例#19
0
 def test_add_new_disease(self):
     repo = PatientRepository()
     patient1 = Patients("K", "A", 2121, "flu")
     repo.add_patient(patient1)
     repo.add_new_disease("Zika", patient1)
     self.assertEqual(patient1.get_disease(), "flu, Zika")
示例#20
0
 def test_update_disease(self):
     repo = PatientRepository()
     patient1 = Patients("A", "B", 101, "flu")
     repo.add_patient(patient1)
     repo.update_disease("Zika", patient1)
     self.assertEqual(patient1.get_disease(), "Zika")