def test_query_where(app): with app.app_context(): u = query_where("patient", f"name = 'patient1'") print(u) uid = u[0][0] utime = u[0][6] assert u[0] == (uid, 'patient1', 'getpatient', 'Male', 18, 12341234, utime, '22222222222')
def test_remove_doctor(app): # Works good cli = app.test_client() login_admin(cli) with app.app_context(): res = cli.get('/admin/deactivate_doctor/1', follow_redirects=True) d = query_where(table_name="doctor", condition="id= 1") assert d[0][10] == False assert res.status_code == 200
def test_add_newpatient(app): # Test adding without being present with app.app_context(): add_newpatient("add_Nid", "Name", "Surname", "Gender", 18) u = query_where("patient", f"national_id ='add_Nid'") # uid is patientid which is serial # utime is cratetime which is timestamp # ulogcode is also created during function call uid = u[0][0] utime = u[0][6] ulogcode = u[0][5] assert u[0] == (uid, 'Name', 'Surname', 'Gender', 18, ulogcode, utime, 'add_Nid')
def test_update_appointment(app): # Works good cli = app.test_client() login_doctor(cli) with app.app_context(): form = { "patient_nid": "33333333333", "diagnosis": "Healthy", "note": "verymuch" } res = cli.post('/doctor/update_appointment/1', data=form, follow_redirects=True) a = query_where("appointment", "diagnosis_comment = 'verymuch'") assert res.status_code == 200 assert a != []
def test_add_patient_no_gender(app): cli = app.test_client() login_doctor(cli) with app.app_context(): form = { "patient_national_id": "00000000000", "patient_name": "test without gender", "patient_surname": "TESTSURNAME", "patient_age": 15, "patient_gender": None } res = cli.post('/doctor/add_patient', data=form, follow_redirects=True) p = query_where("patient", "name = 'test without gender'") assert res.status_code == 200 #assert b"This field is required" in res.data assert p == []
def test_add_patient_no_surname(app): cli = app.test_client() login_doctor(cli) with app.app_context(): form = { "patient_national_id": "00000000000", "patient_name": "test without surname", "patient_surname": None, "patient_age": 25, "patient_gender": "Male" } res = cli.post('/doctor/add_patient', data=form, follow_redirects=True) p = query_where("patient", "name = 'test without surname'") assert p == [] assert res.status_code == 200
def test_add_patient_proper(app): cli = app.test_client() login_doctor(cli) with app.app_context(): form = { "patient_national_id": "00000000000", "patient_name": "test proper input", "patient_surname": "TESTSURNAME", "patient_age": 22, "patient_gender": "Male" } res = cli.post('/doctor/add_patient', data=form, follow_redirects=False) p = query_where(table_name="patient", condition="name= 'test proper input'") assert p != [] assert res.status_code == 302
def test_add_doctor(app): cli = app.test_client() login_admin(cli) with app.app_context(): form = { "national_id": "12341234123", "name": "newdoc", "surname": "surdoc", "password": "******", "confirm": "1", "username": "******", "hospital": "hosp", "title": "Dr.", "profession": "Heart" } res = cli.post('/admin/add_doctor', data=form, follow_redirects=False) p = query_where(table_name="doctor", condition="name= 'newdoc'") assert p != [] assert res.status_code == 302
def patient_details(): patientid = session["patient"][0] row = query_where("patient", "id = " + str(patientid)) return render_template('patient/patient_details.html', row=row[0])
def test_delete_patient_with_national_id(app): with app.app_context(): delete_patient_with_national_id('National_id1') u = query_where("patient", f"national_id = 'National_id1'") assert u == []
def test_add_appointment(app, mocker): cli = app.test_client() login_doctor(cli) with app.app_context(): # mock get_prediction to return corrupted mocker.patch('smarthealth_web.doctor.get_prediction', return_value=b"Corrupted") form = { "patient_national_id": "11111111111", "diagnosis": "Healthy", "note": "with_unavailable_prediction" } res = cli.post('/doctor/add_appointment', data=form, follow_redirects=True) a = query_where("appointment", "diagnosis_comment = 'with_unavailable_prediction'") assert res.status_code == 200 assert b"Doctor's Diagnosis" in res.data assert a[0][1] == "Error" # test with prediction = Positive mocker.patch('smarthealth_web.doctor.get_prediction', return_value=b"Pos") form = { "patient_national_id": "11111111111", "diagnosis": "Sick", "note": "with_pos_prediction" } res = cli.post('/doctor/add_appointment', data=form, follow_redirects=True) a = query_where("appointment", "diagnosis_comment = 'with_pos_prediction'") assert res.status_code == 200 assert b"Doctor's Diagnosis" in res.data assert a[0][1] == "Hypertension" # test with prediction = Negative mocker.patch('smarthealth_web.doctor.get_prediction', return_value=b"Neg") form = { "patient_national_id": "11111111111", "diagnosis": "Good Condition", "note": "with_neg_prediction" } res = cli.post('/doctor/add_appointment', data=form, follow_redirects=True) a = query_where("appointment", "diagnosis_comment = 'with_neg_prediction'") assert res.status_code == 200 assert b"Doctor's Diagnosis" in res.data assert a[0][1] == "Healthy" # test with system fault in prediction side mocker.patch('smarthealth_web.doctor.get_prediction', return_value=b"a") form = { "patient_national_id": "11111111111", "diagnosis": "Good Condition", "note": "with_system_fault_prediction" } res = cli.post('/doctor/add_appointment', data=form, follow_redirects=True) a = query_where("appointment", "diagnosis_comment = 'with_system_fault_prediction'") assert res.status_code == 200 assert b"Doctor's Diagnosis" in res.data assert a[0][1] == "System Fault"
def doctor_details(doctor_id): row = query_where("doctor", "id = " + doctor_id) return render_template('patient/doctor_details.html', row=row[0])
def patient_details(patient_id): row = dboperations.query_where("patient", "id = " + patient_id) return render_template('doctor/patient_details.html', row=row[0])
def test_update_appointment(app): with app.app_context(): update_appointment(1,'11111111111','unhealthy','veryunhealthy') u = query_where("appointment","id = 1") assert u[0][3] == "veryunhealthy"
def test_deactivate_doctor(app): with app.app_context(): deactivate_doctor(4) u = query_where("doctor","name = 'deactivdoctor1'") assert u[0][10] == False
def home_page(): rows = query_where("DOCTOR", "isActive != 'no'") admin_names = list() for r in range(len(rows)): admin_names.append(get_admin_name_by_id(rows[r][8])) return render_template("admin/admin_dashboard.html", rows=rows, len=len(rows), admin_names=admin_names)
def test_get_patient_by_nid(app): with app.app_context(): p = get_patient_by_nid("44444444444") a = query_where("patient", "name = 'pgettest'") assert a[0] == p