-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
159 lines (121 loc) · 6.71 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
from userManager import UserManager
from centreManager import CentreManager
from appointmentManager import AppointmentManager
import pytest
class Tests(object):
def setup_method(self):
self.centreManager = CentreManager()
self.userManager = UserManager(self.centreManager)
self.appointmentManager = AppointmentManager()
self.centreManager.addProviders(self.userManager)
# (1) BOOK AN APPOINTMENT
# 4
# (i) Testing that the appointment added is in the patient class and the provider class
def test_book_appointment(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/31/2018","Biopsy Required")
# Check that the appointment is in the provider class
provider = self.userManager.getID("[email protected]")
providerAppointment = provider.getSpecificAppointment(0)
assert(providerAppointment.provider == "[email protected]")
assert(providerAppointment.patient == "[email protected]")
assert(providerAppointment.date == "12/31/2018")
assert(providerAppointment.time == "00.00-00.30")
assert(providerAppointment.reason == "Biopsy Required")
# Check that the appointment is in the patient class
patient = self.userManager.getID("[email protected]")
patientAppointment = patient.getSpecificAppointment(0)
assert(patientAppointment.provider == "[email protected]")
assert(patientAppointment.patient == "[email protected]")
assert(patientAppointment.date == "12/31/2018")
assert(patientAppointment.time == "00.00-00.30")
assert(patientAppointment.reason == "Biopsy Required")
# (ii) Check that booking an appointment in the same timeslot does not work
def test_book_same_time_slot_appointment(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/31/2018", "Influenza")
status = self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/31/2018","Same Time slot")
assert(status == "Time Slot Taken")
# (iii) provider makes an appointment for himself/herself
def test_provider_makes_appointment(self): ##
status = self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/1/2018", "Arthiritis")
assert(status == "Provider making appointment")
# (additional) Check that you cannot book an appointment in the past
def test_book_past_appointment(self): ##
status = self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "09/24/2018","Constipation")
assert(status == "Date in the past")
# (2) VIEW PATIENT HISTORY
# 2
# testing that the history is saved and can be accessed
def test_get_appointment_history(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/31/2018", "High Blood Pressure")
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.30-01.00", "12/31/2018","Vomiting")
user = self.userManager.getID("[email protected]")
assert(len(self.appointmentManager.getAppointments(user)) == 2)
# test updating with multiple people booking and 2 wanting the same time
def multiple_appointments_clash(self):
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "04.00-04.30", "12/31/2018","Biopsy Required")
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.30-01.00", "12/31/2018", "Mole on foot")
# this appointment has the same time and date as the previous appointment
clash = self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.30-01.00", "12/31/2018","Mole on foot")
assert(clash == "Time Slot Taken")
user = self.userManager.getID("[email protected]")
assert(len(self.appointmentManager.getAppointments(user)) == 1)
# (3) MANAGE A PATIENT HISTORY
# 4
# test to ensure the provider can update appointment with notes and medicine prescribed
def notes_and_medicine(self):
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "09.00-09.30", "11/23/2018","Biopsy Required")
user = self.userManager.getID("[email protected]")
appointment = self.appointmentManager.getAppointmentUsingDate(user,
"11/23/2018", "09.00-09.30")
notes = "Baby Shark"
medicine = "Doo doo doo doo"
self.appointmentManager.updateAppointment(appointment, notes, medicine)
assert(appointment.notes == "Baby Shark")
assert(appointment.prescribedMedicine == "Doo doo doo doo")
# updating notes from a previously inputted notes and medicine
def test_update_appointment(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "09.00-09.30", "11/23/2018", "Biopsy Required")
user = self.userManager.getID("[email protected]")
appointment = self.appointmentManager.getAppointmentUsingDate(user,
"11/23/2018", "09.00-09.30")
appointment.notes = "This person did not require a doctor"
appointment.prescribedMedicine = "Obecalp pills"
newNotes = "I was wrong"
newMedicine = "Sugar"
self.appointmentManager.updateAppointment(appointment, newNotes, newMedicine)
assert(appointment.notes == "This person did not require a doctor\nI was wrong")
assert(appointment.prescribedMedicine == "Obecalp pills\nSugar")
# updating notes then realising no updates are needed -> NULL submission
def test_update_appointment_with_nothing(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "08.00-08.30", "11/23/2018", "Biopsy Required")
user = self.userManager.getID("[email protected]")
appointment = self.appointmentManager.getAppointmentUsingDate(user,
"11/23/2018", "08.00-08.30")
appointment.notes = "This person did not require a doctor"
appointment.prescribedMedicine = "Obecalp pills"
newNotes = ""
newMedicine = ""
self.appointmentManager.updateAppointment(appointment, newNotes, newMedicine)
assert(appointment.notes == "This person did not require a doctor\n")
assert(appointment.prescribedMedicine == "Obecalp pills\n")
# Test getting the history with an email that does not have any appointments
def test_get_wrong_id_history(self): ##
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.00-00.30", "12/31/2018", "Biopsy Required")
self.appointmentManager.addAppointment(self.userManager, "[email protected]",
"[email protected]", "00.30-01.00", "12/31/2018", "Mole on foot")
user = self.userManager.getID("[email protected]")
assert(len(self.appointmentManager.getAppointments(user)) == 0)