def test_practice_profile_view_manager(self): staff = OfficeStaff(user=self.user) staff.current_practice = self.practice staff.save() staff.practices.add(self.practice) manager = Office_Manager(user=staff, practice=self.practice, manager_role=1) manager.save() response = self.client.post( reverse('MHLogin.MHLPractices.views.practice_profile_view')) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'Profile/practice_profile_view.html') manager.manager_role = 2 manager.save() self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'Profile/practice_profile_view.html')
def testSetOfficeStaffResultList(self): # create office staff staff = create_office_staff(get_random_username(), "staff", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) nurse = Nurse(user=staff2) nurse.save() staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) mgr = Office_Manager(user=staff3) practice = PracticeLocation( practice_address1='555 Pleasant Pioneer Grove', practice_address2='Trailer Q615', practice_city='Mountain View', practice_state='CA', practice_zip='94040-4104', practice_lat=37.36876, practice_longit=-122.081864) practice.save() mgr.manager_role = 1 mgr.practice = practice mgr.save() mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "") mhlu.mdcom_phone = '9002000001' mhlu.save() self.assertEqual(0, len(setOfficeStaffResultList([])), 'test failed for setOfficeStaffResultList null') self.assertEqual(1, len(setOfficeStaffResultList([staff])), 'test failed for setOfficeStaffResultList staff') # self.assertEqual(1, len(setOfficeStaffResultList([nurse])), #'test failed for setOfficeStaffResultList nurse') self.assertEqual(1, len(setOfficeStaffResultList([mgr])), 'test failed for setOfficeStaffResultList mgr') self.assertEqual(3, len(setOfficeStaffResultList([staff, nurse.user, mgr])), 'test failed for setOfficeStaffResultList') self.assertEqual(3, len(setOfficeStaffResultList([staff, nurse.user, mgr], staff)), 'test failed for setOfficeStaffResultList')
def testGetUserInfo(self): mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "") mhlu.mdcom_phone = '9002000001' mhlu.save() mhlu_id = mhlu.id return_data1 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/generic_128.png', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': mhlu_id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'mhluser', 'office_state': u'CA', 'office_zip': u'', 'staff_type': ''} self.assertEqual(Http404, getUserInfo(mhlu_id + 1, None), 'test failed for getUserInfo') self.assertEqual(return_data1, getUserInfo(mhlu_id), 'test failed for getUserInfo mhluser') # create provider for test provider = create_user(get_random_username(), "provider", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider) provider.mdcom_phone = '9002000002' provider.save() return_data2 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/avatar2.png', 'specialty': 'NP/PA/Midwife', 'mdcom_phone': u'9002000002', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': provider.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'provider', 'office_state': u'CA', 'office_zip': u'', 'staff_type': ''} self.assertEqual(return_data2, getUserInfo(provider.user.id), 'test failed for getUserInfo provider') # create physician provider1 = create_user(get_random_username(), "physician", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider) provider1.mdcom_phone = '9002000002' provider1.save() phy = Physician(user=provider1) phy.specialty = 'AC' phy.save() return_data3 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/avatar2.png', 'specialty': u'Acupuncture', 'mdcom_phone': u'9002000002', 'office_city': u'Palo Alto', 'accepting_patients': True, 'id': phy.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'physician', 'office_state': u'CA', 'office_zip': u'', 'staff_type': ''} self.assertEqual(return_data3, getUserInfo(phy.user.user.id), 'test failed for getUserInfo physician') # create office staff staff = create_office_staff(get_random_username(), "staff", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) return_data4 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': staff.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'staff', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff'} self.assertEqual(return_data4, getUserInfo(staff.user.id), 'test failed for getUserInfo staff') # create nurse staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) nurse = Nurse(user=staff2) nurse.save() return_data5 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/nurse.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': nurse.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'nurse', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff'} self.assertEqual(return_data5, getUserInfo(nurse.user.user.id), 'test failed for getUserInfo nurse') # create office staff staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) mgr = Office_Manager(user=staff3) practice = PracticeLocation( practice_address1='555 Pleasant Pioneer Grove', practice_address2='Trailer Q615', practice_city='Mountain View', practice_state='CA', practice_zip='94040-4104', practice_lat=37.36876, practice_longit=-122.081864) practice.save() mgr.manager_role = 1 mgr.practice = practice mgr.save() return_data5 = {'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': mgr.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'maneger', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Manager'} self.assertEqual(return_data5, getUserInfo(mgr.user.user.id), 'test failed for getUserInfo maneger')
def testGetUserInfo(self): mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "") mhlu.mdcom_phone = '9002000001' mhlu.save() mhlu_id = mhlu.id return_data1 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/generic_128.png', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': mhlu_id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'mhluser', 'office_state': u'CA', 'office_zip': u'', 'staff_type': '' } self.assertEqual(Http404, getUserInfo(mhlu_id + 1, None), 'test failed for getUserInfo') self.assertEqual(return_data1, getUserInfo(mhlu_id), 'test failed for getUserInfo mhluser') # create provider for test provider = create_user(get_random_username(), "provider", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider) provider.mdcom_phone = '9002000002' provider.save() return_data2 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/avatar2.png', 'specialty': 'NP/PA/Midwife', 'mdcom_phone': u'9002000002', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': provider.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'provider', 'office_state': u'CA', 'office_zip': u'', 'staff_type': '' } self.assertEqual(return_data2, getUserInfo(provider.user.id), 'test failed for getUserInfo provider') # create physician provider1 = create_user(get_random_username(), "physician", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=Provider) provider1.mdcom_phone = '9002000002' provider1.save() phy = Physician(user=provider1) phy.specialty = 'AC' phy.save() return_data3 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/avatar2.png', 'specialty': u'Acupuncture', 'mdcom_phone': u'9002000002', 'office_city': u'Palo Alto', 'accepting_patients': True, 'id': phy.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'physician', 'office_state': u'CA', 'office_zip': u'', 'staff_type': '' } self.assertEqual(return_data3, getUserInfo(phy.user.user.id), 'test failed for getUserInfo physician') # create office staff staff = create_office_staff(get_random_username(), "staff", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) return_data4 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': staff.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'staff', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff' } self.assertEqual(return_data4, getUserInfo(staff.user.id), 'test failed for getUserInfo staff') # create nurse staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) nurse = Nurse(user=staff2) nurse.save() return_data5 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/nurse.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': nurse.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'nurse', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Staff' } self.assertEqual(return_data5, getUserInfo(nurse.user.user.id), 'test failed for getUserInfo nurse') # create office staff staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) mgr = Office_Manager(user=staff3) practice = PracticeLocation( practice_address1='555 Pleasant Pioneer Grove', practice_address2='Trailer Q615', practice_city='Mountain View', practice_state='CA', practice_zip='94040-4104', practice_lat=37.36876, practice_longit=-122.081864) practice.save() mgr.manager_role = 1 mgr.practice = practice mgr.save() return_data5 = { 'last_name': u'thj', 'office_address1': u'555 Bryant St.', 'office_address2': u'', 'photo': '/media/images/photos/staff_icon.jpg', 'specialty': '', 'mdcom_phone': '', 'office_city': u'Palo Alto', 'accepting_patients': False, 'id': mgr.user.user.id, 'custom_logos': get_custom_logos(mhlu_id), 'first_name': u'maneger', 'office_state': u'CA', 'office_zip': u'', 'staff_type': 'Office Manager' } self.assertEqual(return_data5, getUserInfo(mgr.user.user.id), 'test failed for getUserInfo maneger')
def testSetOfficeStaffResultList(self): # create office staff staff = create_office_staff(get_random_username(), "staff", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) staff2 = create_office_staff(get_random_username(), "nurse", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) nurse = Nurse(user=staff2) nurse.save() staff3 = create_office_staff(get_random_username(), "maneger", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "", uklass=OfficeStaff) mgr = Office_Manager(user=staff3) practice = PracticeLocation( practice_address1='555 Pleasant Pioneer Grove', practice_address2='Trailer Q615', practice_city='Mountain View', practice_state='CA', practice_zip='94040-4104', practice_lat=37.36876, practice_longit=-122.081864) practice.save() mgr.manager_role = 1 mgr.practice = practice mgr.save() mhlu = create_user(get_random_username(), "mhluser", "thj", "demo", "555 Bryant St.", "Palo Alto", "CA", "") mhlu.mdcom_phone = '9002000001' mhlu.save() self.assertEqual(0, len(setOfficeStaffResultList([])), 'test failed for setOfficeStaffResultList null') self.assertEqual(1, len(setOfficeStaffResultList([staff])), 'test failed for setOfficeStaffResultList staff') # self.assertEqual(1, len(setOfficeStaffResultList([nurse])), #'test failed for setOfficeStaffResultList nurse') self.assertEqual(1, len(setOfficeStaffResultList([mgr])), 'test failed for setOfficeStaffResultList mgr') self.assertEqual( 3, len(setOfficeStaffResultList([staff, nurse.user, mgr])), 'test failed for setOfficeStaffResultList') self.assertEqual( 3, len(setOfficeStaffResultList([staff, nurse.user, mgr], staff)), 'test failed for setOfficeStaffResultList')