Ejemplo n.º 1
0
	def test_getEvents(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)

		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()

		errData = {}
		successDate = {'fromDate': datetime.datetime(2012, 12, 12), 'toDate': datetime.datetime(2012, 12, 17)}

		#get method
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.getEvents', args=(self.practice.id, self.group.id)), data=successDate)
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'DateEntry.html')

		#error data
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents', 
			args=(self.practice.id, self.group.id)), data=errData)
		self.assertEqual(response.status_code, 403)

		#error call group
		group2 = CallGroup(description='test', team='team')
		group2.save()
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents', 
			args=(self.practice.id, group2.id)), data=errData)
		self.assertEqual(response.status_code, 403)

		#success data and find 0 event
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents', 
			args=(self.practice.id, self.group.id)), data=successDate)
		self.assertEqual(response.status_code, 200)
		data = json.loads(response.content)
		self.assertEqual(data['redoSize'], 0)
		self.assertEqual(data['undoSize'], 0)
		self.assertEqual(data['datas'], '[]')

		#success data and find 1 event
		event = EventEntry(creator=self.user,
						oncallPerson=self.user,
						callGroup=self.group,
						startDate=datetime.datetime(2012, 12, 1),
						endDate=datetime.datetime(2012, 12, 30),
						title='test event',
						oncallLevel='0',
						eventStatus=1,
						checkString='abc'
						)
		event.save()

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents', 
			args=(self.practice.id, self.group.id)), data=successDate)
		self.assertEqual(response.status_code, 200)
		data = json.loads(response.content)
		self.assertEqual(data['redoSize'], 0)
		self.assertEqual(data['undoSize'], 0)
		d = json.loads(data['datas'])
		self.assertEqual(len(d), 1)
		self.assertEqual(d[0]['pk'], event.pk)
Ejemplo n.º 2
0
    def test_isCallGroupStaff(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.call_group = call_group
        practice.save()

        user = create_user('user5', 'us', 'er', 'demo')

        #a mhluser call this method
        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, False)

        staff = OfficeStaff(user=user)
        staff.save()
        staff.practices.add(practice)

        #a staff call this method
        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, True)

        #a manager call this method
        manager = Office_Manager(user=staff, practice=practice, manager_role=1)
        manager.save()

        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, True)
Ejemplo n.º 3
0
	def test_practice_info(self):
		organization_type = create_org_type()
		practice = ct_practice('name', organization_type)

		request = generateHttpRequest()

		#a provider login
		result = practice_info(request, practice.id)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(msg['data']['id'], practice.id)

		#a staff login
		staff = OfficeStaff(user=request.user)
		staff.save()
		manager = Office_Manager(user=staff, practice=practice, manager_role=2)
		manager.save()

		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 100
		assn.save(request)

		#invalid practice
		result = practice_info(request, 0)
		self.assertEqual(result.status_code, 400)
		msg = json.loads(result.content)
		self.assertEqual(msg['errno'], 'PF003')

		#valid practice
		result = practice_info(request, practice.id)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(msg['data']['id'], practice.id)
Ejemplo n.º 4
0
	def test_new_event(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		#get method
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, self.call_group.id)))
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, "bulkOperation.html")

		#post method

		#not save new event,provider is not in the call group
		provider = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider.save()
		checkString = 'Ca69J2X6l8'
		newEventInvalidData = {'data': '[{"pk":null,"model":"Scheduler.evententry","fields":'\
			'{"oncallPerson":"' + str(provider.id) + '","eventType":"0",'\
				'"startDate":"2012-12-19 08:00:00","endDate":"2012-12-20 08:00:00",'\
					'"checkString":"' + checkString + '"}}]',
			'view': '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'}

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, self.call_group.id)), data=newEventInvalidData)
		self.assertEqual(response.status_code, 200)
		msg = json.loads(response.content)
		self.assertEqual(msg['error'][0], checkString + ', error saving new object')

		#save new event, provider is in the call group
		provider2 = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider2.save()

		cgm = CallGroupMember(call_group=self.call_group, member=provider2, alt_provider=1)
		cgm.save()

		checkString = 'Ca69J2X6l8'
		newEventInvalidData = {'data': '[{"pk":null,"model":"Scheduler.evententry","fields":{"oncallPerson":"' + 
			str(provider2.id) + '","eventType":"0","startDate":"2012-12-19 08:00:00","endDate":"2012-12-20 08:00:00",\
				"checkString":"' + checkString + '"}}]',
				'view': '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'}

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, self.call_group.id)), data=newEventInvalidData)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(EventEntry.objects.count(), 1)

		#403
		call_group2 = CallGroup(description='test2', team='team')
		call_group2.save()

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, call_group2.id)), data=newEventInvalidData)
		self.assertEqual(response.status_code, 403)
Ejemplo n.º 5
0
	def test_local_office(self):
		request = generateHttpRequest()

		#a provider call this method
		result = local_office(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		
		self.assertEqual(len(msg['data']['practices']), 0)

		#a office manager login but has not current practice
		organization_type = create_org_type()
		practice = ct_practice('name', organization_type)
		staff = OfficeStaff(user=request.user)
		staff.save()
		manager = Office_Manager(user=staff, practice=practice, manager_role=2)
		manager.save()

		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 100
		assn.save(request)

		result = local_office(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['practices']), 0)

		#a office manager login and has current practice
		staff.current_practice = practice
		result = local_office(request)
		self.assertEqual(result.status_code, 200)
		msg = json.loads(result.content)
		self.assertEqual(len(msg['data']['practices']), 0)
Ejemplo n.º 6
0
	def test_getLevelByStaff(self):
		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()
		user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		
		#not a manager login
		result = get_level_by_staff(user, practice)
		self.assertEqual(result, 0)
		
		staff = OfficeStaff(user=user)
		staff.save()
		
		manager = Office_Manager(user=staff, practice=practice, manager_role=2)
		manager.save()
		
		#a manager login
		result = get_level_by_staff(staff.id, practice)
		self.assertEqual(result, 2)
Ejemplo n.º 7
0
    def test_getLevelByStaff(self):
        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()
        user = create_user('practicemgr1', 'lin', 'xing', 'demo')

        #not a manager login
        result = get_level_by_staff(user, practice)
        self.assertEqual(result, 0)

        staff = OfficeStaff(user=user)
        staff.save()

        manager = Office_Manager(user=staff, practice=practice, manager_role=2)
        manager.save()

        #a manager login
        result = get_level_by_staff(staff.id, practice)
        self.assertEqual(result, 2)
Ejemplo n.º 8
0
    def test_local_office(self):
        request = generateHttpRequest()

        #a provider call this method
        result = local_office(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)

        self.assertEqual(len(msg['data']['practices']), 0)

        #a office manager login but has not current practice
        organization_type = create_org_type()
        practice = ct_practice('name', organization_type)
        staff = OfficeStaff(user=request.user)
        staff.save()
        manager = Office_Manager(user=staff, practice=practice, manager_role=2)
        manager.save()

        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 100
        assn.save(request)

        result = local_office(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['practices']), 0)

        #a office manager login and has current practice
        staff.current_practice = practice
        result = local_office(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['practices']), 0)
Ejemplo n.º 9
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice1.save()
		
		OrganizationRelationship.objects.create(organization=practice,\
				parent=practice1,create_time=int(time.time()),billing_flag=True)
		cls.practice = practice
		cls.practice1 = practice1
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
Ejemplo n.º 10
0
    def setUp(self):
        clean_db_datas()
        self.user = create_user(get_random_username(), 'yang', 'peng', 'demo')
        self.organization = create_organization()
        self.parent_organization = create_parent_organization()
        self.organization.save_parent_org(parent_org=self.parent_organization)
        staff = OfficeStaff()
        staff.user = self.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.current_practice = self.organization
        staff.save()
        staff.practices.add(self.organization)

        mgr = Office_Manager(user=staff,
                             practice=self.organization,
                             manager_role=2)
        mgr.save()

        self.provider = create_user(get_random_username(),
                                    "doc",
                                    "holiday",
                                    "demo",
                                    uklass=Provider)
        self.provider.current_practice = self.parent_organization
        self.provider.save()
        self.provider.practices.add(self.parent_organization)
Ejemplo n.º 11
0
	def test_isCallGroupStaff(self):
		call_group = CallGroup(description='test', team='team')
		call_group.save()
		
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.call_group = call_group
		practice.save()
		
		
		user = create_user('user5', 'us', 'er', 'demo')
		
		#a mhluser call this method
		result = isCallGroupStaff(user, call_group.pk)
		self.assertEqual(result, False)
		
		staff = OfficeStaff(user=user)
		staff.save()
		staff.practices.add(practice)
		
		#a staff call this method
		result = isCallGroupStaff(user, call_group.pk)
		self.assertEqual(result, True)
		
		#a manager call this method
		manager = Office_Manager(user=staff, practice=practice, manager_role=1)
		manager.save()
		
		result = isCallGroupStaff(user, call_group.pk)
		self.assertEqual(result, True)
Ejemplo n.º 12
0
 def testGetDComNumber(self):
     user = create_user(get_random_username(),
                        "tian",
                        "thj",
                        "demo",
                        "555 Bryant St.",
                        "Palo Alto",
                        "CA",
                        "",
                        uklass=OfficeStaff)
     user.mdcom_phone = '9001234123'
     user.save()
     practice = PracticeLocation(
         practice_name='test',
         practice_longit='0.1',
         practice_lat='0.0',
     )
     practice.save()
     mgr = Office_Manager(user=user, practice=practice, manager_role=2)
     mgr.save()
     response = self.client.get(reverse\
       ('MHLogin.api.v1.views_account.getDComNumber'), **self.extra)
     self.assertEqual(response.status_code, 200, response.status_code)
     msg = json.loads(response.content)
     self.assertEqual(len(msg), 2)
Ejemplo n.º 13
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		cls.user1 = create_user('practicemgr11', 'y', 'p', 'demo')

		cls.broker = create_user("broker1", "bro", "1", "demo", 
							"123 Main St.", "Phoenix", "AZ", uklass=Broker)

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice1.save()

		OrganizationRelationship.objects.create(organization=practice,\
			parent=practice1, create_time=int(time.time()), billing_flag=True)

		cls.practice = practice
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)

		cls.provider = Provider(user=cls.user1, office_lat=0.0, office_longit=0.0, current_practice = practice)
		cls.provider.mdcom_phone = '5948949899' 
		cls.provider.save()
#		
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
Ejemplo n.º 14
0
    def test_getPenddings(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=2)
        manager.save()

        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.getPenddings'))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 0)

        pend = Pending_Association(from_user=self.user,
                                   to_user=self.user,
                                   practice_location=self.practice,
                                   created_time=datetime.datetime.now())
        pend.save()

        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.getPenddings'))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 1)
Ejemplo n.º 15
0
    def test_practice_info(self):
        organization_type = create_org_type()
        practice = ct_practice('name', organization_type)

        request = generateHttpRequest()

        #a provider login
        result = practice_info(request, practice.id)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(msg['data']['id'], practice.id)

        #a staff login
        staff = OfficeStaff(user=request.user)
        staff.save()
        manager = Office_Manager(user=staff, practice=practice, manager_role=2)
        manager.save()

        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 100
        assn.save(request)

        #invalid practice
        result = practice_info(request, 0)
        self.assertEqual(result.status_code, 400)
        msg = json.loads(result.content)
        self.assertEqual(msg['errno'], 'PF003')

        #valid practice
        result = practice_info(request, practice.id)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(msg['data']['id'], practice.id)
Ejemplo n.º 16
0
	def test_saveViewInfo(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		#get method
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.saveViewInfo', 
			args=(self.practice.id, self.call_group.id)))
		self.assertEqual(response.status_code, 200)
		msg = json.loads(response.content)
		self.assertEqual(msg['view'], '')

		#403
		call_group2 = CallGroup(description='test2', team='team')
		call_group2.save()

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.saveViewInfo', 
			args=(self.practice.id, call_group2.id)))
		self.assertEqual(response.status_code, 403)

		#post method without session
		view = {'view': '{"name": "month", "start": "2012-12-01 00:00:00", "end": "2013-01-01 00:00:00"}'}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.saveViewInfo', 
			args=(self.practice.id, self.call_group.id)), data=view)
		self.assertEqual(response.status_code, 200)
		msg = json.loads(response.content)
		self.assertEqual(msg['view'], view['view'])
Ejemplo n.º 17
0
	def test_getMembers(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		#0 member found
		response = self.client.post(reverse('MHLogin.MHLCallGroups.views.getMembers', args=(self.call_group.id,)))
		self.assertEqual(response.status_code, 200)

		#1 member found
		provider = Provider(username='******', first_name='tes', last_name="meister", email='*****@*****.**',
					office_lat=0.0, office_longit=0.0)
		provider.save()
		member = CallGroupMember(call_group=self.call_group, member=provider, alt_provider=1)
		member.save()
		response = self.client.post(reverse('MHLogin.MHLCallGroups.views.getMembers', args=(self.call_group.id,)))
		self.assertEqual(response.status_code, 200)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 1)
		self.assertEqual(msg[0][0], provider.id)

		#403
		call_group2 = CallGroup(description='test2', team='team')
		call_group2.save()

		response = self.client.post(reverse('MHLogin.MHLCallGroups.views.getMembers', args=(call_group2.id,)))
		self.assertEqual(response.status_code, 403)
Ejemplo n.º 18
0
def changeRole(request):
	id = request.POST['pk']
	newRole = request.POST['newRole']
	practice = request.org
	oldRole = str(get_level_by_staff(id, practice))
	if newRole == '0':
		Office_Manager.objects.filter(user=id, practice=practice).delete()
	else:
		os = OfficeStaff.objects.get(pk=id)
		if oldRole == '0':
			obm = Office_Manager(user=os, practice=practice, manager_role=newRole)
			obm.save()
		else:
			om = Office_Manager.objects.get(user=os, practice=practice)
			om.manager_role = newRole
			om.save()

	#after change staff role susscee and delete session
	sessions = Session.objects.all()
	for session in sessions:
		values = session.get_decoded()
		if 'MHL_UserIDs' in values and 'MHLUser' in values['MHL_UserIDs']:
			staffID = values['MHL_UserIDs']['MHLUser']
			session_key = session.session_key
			os = OfficeStaff.objects.get(pk=id)
			if os.user.id == staffID:
				ss = Session.objects.get(session_key=session_key)
				ss.delete()
	return HttpResponse(json.dumps('OK'))
Ejemplo n.º 19
0
    def test_addProviderToPractice(self, start_thread):
        #user is a manager
        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=2)
        manager.save()

        #invalid assoc id
        assocID = {'assoc_id': 'a'}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.addProviderToPractice'),
            data=assocID)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['err'], _('A server error has occurred.'))

        #valid assoc id
        to_user = create_user(
            'p2',
            'lin2',
            'xing2',
            'demo',
            '',
            '',
            '',
            '',
        )
        provider = Provider(username='******',
                            first_name='first',
                            last_name="last",
                            email='*****@*****.**',
                            user=self.user,
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        pend = Pending_Association(from_user=self.user,
                                   to_user=to_user,
                                   practice_location=self.practice,
                                   created_time=datetime.datetime.now())
        pend.save()
        assocID = {'assoc_id': pend.id}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.addProviderToPractice'),
            data=assocID)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg, 'ok')
        self.assertEqual(
            Log_Association.objects.get(association_id=pend.id).action, 'ACC')
        self.assertEqual(Pending_Association.objects.count(), 0)
        self.assertEqual(
            self.practice
            in Provider.objects.get(pk=provider.pk).practices.all(), True)
        mems = CallGroupMember.objects.filter(call_group=self.call_group)
        self.assertEqual(len(mems), 1)
Ejemplo n.º 20
0
	def setUpClass(cls):
		clean_db_datas()
		cls.call_group = CallGroup.objects.create(description='test', team='team')
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		cls.user1 = create_user('practicemgr2', 'yang', 'peng', 'demo')
		cls.user2 = create_user('practicemgr234', 'yang1', 'peng1', 'demo')

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',
								call_group = cls.call_group,)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',
								call_group = cls.call_group,)
		practice1.save()
		
		OrganizationRelationship.objects.create(organization=practice,\
				parent=practice1,create_time=int(time.time()),billing_flag=True)
		cls.practice = practice
		cls.practice1 = practice1
		
		provider = Provider(user=cls.user1, office_lat=0.0, office_longit=0.0, current_practice = practice)
		provider.save()
		provider.practices.add(practice)
		provider.practices.add(practice1)
		cls.provider = provider
		
		cls.provider2 = Provider(username="******", first_name="doc", 
								last_name="holiday", office_lat=0.0, office_longit=0.0)
		cls.provider2.set_password("holiday")
		cls.provider2.save()
		VMBox_Config(owner=cls.provider2).save()
		
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		
		cls.event = EventEntry(creator=cls.user,
						oncallPerson=cls.user1,
						callGroup=cls.call_group,
						startDate=datetime.datetime(2012, 12, 1),
						endDate=datetime.datetime.now()+datetime.timedelta(days = 2),
						title='test event',
						oncallLevel='0',
						eventStatus=1,
						checkString='abc'
						)
		cls.event.save()
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
		generate_keys_for_users(output=DevNull())
Ejemplo n.º 21
0
    def test_isMultiCallGroupManager(self):
        #init practice and call group
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice.call_groups.add(call_group)

        user = create_user('user1', 'us', 'er', 'demo')

        #only mhluser call method
        result = isMultiCallGroupManager(user, practice.id, call_group.id)
        self.assertEqual(result, False)

        #staff call method
        staff = OfficeStaff(user=user)
        staff.save()
        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, False)

        practice2 = PracticeLocation(
            practice_name='test2',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice2.save()
        practice2.call_groups.add(call_group)

        #manager call method
        staff.practices.add(practice)
        staff.save()
        manager = Office_Manager(user=staff, practice=practice, manager_role=1)
        manager.save()
        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, True)

        #manager with specialty call method
        specialty_name = 'Specialty A'
        specialty1 = Specialty()
        specialty1.name = specialty_name
        specialty1.practice_location = practice
        specialty1.number_selection = 3
        specialty1.save()
        specialty1.call_groups.add(call_group)

        manager2 = Office_Manager(user=staff,
                                  practice=practice2,
                                  manager_role=1)
        manager2.save()

        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, True)
Ejemplo n.º 22
0
class GetParentTypesByTypeidTest(TestCase):
    org_type = None
    admin = None
    manager = None
    organization = None

    def setUp(self):
        clean_db_datas()

        OrganizationType.objects.all().delete()
        org_setting = OrganizationSetting()
        org_setting.save()
        self.org_type = OrganizationType(name="Test Org Type1",
                                         organization_setting=org_setting,
                                         is_public=True)
        self.org_type.save()

        self.organization = create_organization()

        self.admin = create_user('admin',
                                 'Morris',
                                 'Kelly',
                                 'demo',
                                 uklass=Administrator)
        staff = create_user('practicemgr1',
                            'Practice',
                            'Mgr',
                            'demo',
                            uklass=OfficeStaff)
        staff.practices.add(self.organization)
        staff.save()

        self.manager = Office_Manager(user=staff,
                                      practice=self.organization,
                                      manager_role=1)
        self.manager.save()

    def test_get_parent_types_by_typeid(self):
        create_multiple_organization_types(self.org_type, num=10)
        self.assertEqual(1, len(get_parent_types_by_typeid(self.org_type.id)))
        with self.assertRaises(Exception):
            get_parent_types_by_typeid('2sadfa')
        with self.assertRaises(Exception):
            get_parent_types_by_typeid('')

        create_multiple_organization_types(self.org_type,
                                           num=10,
                                           is_public=False)
        self.assertEqual(1, len(get_parent_types_by_typeid(self.org_type.id)))
        self.assertEqual(
            0, len(get_parent_types_by_typeid(self.org_type.id,
                                              is_public=True)))
        self.assertEqual(0, len(get_parent_types_by_typeid(None)))

    def tearDown(self):
        pass
Ejemplo n.º 23
0
	def done(self, request, form_list):
		inviteform = form_list[0]
		userform = form_list[1]
		invite = Invitation.objects.get(code=inviteform.cleaned_data['code'], userType=100)
		if len(form_list) > 2:
			practiceform = form_list[2]
			practice = practiceform.save(commit=False)
			practice.practice_lat = practiceform.cleaned_data['practice_lat']
			practice.practice_longit = practiceform.cleaned_data['practice_longit']
			practice.organization_type_id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
			callgroup = CallGroup(description=practiceform.cleaned_data['practice_name'])
			callgroup.save()
			practice.call_group = callgroup
			practice.save()
			org_relation = OrganizationRelationship(organization=practice, 
				parent_id=RESERVED_ORGANIZATION_ID_DOCTORCOM, create_time=time.time())
			org_relation.save()
			manager_role = 2
		else:
			practice = invite.assignPractice
			manager_role = 1

		user = userform.save(commit=False)
		user.set_password(userform.cleaned_data['password1'])
		# use mhluser's address1, address2, city, state, zip to store "address" information,
		user.address1 = practice.practice_address1
		user.address2 = practice.practice_address2
		user.city = practice.practice_city
		user.state = practice.practice_state
		user.zip = practice.practice_zip
		user.lat = practice.practice_lat
		user.longit = practice.practice_longit
		user.tos_accepted = True
		if invite.recipient == request.POST['email']:
			user.email_confirmed = True

		user.save()

		staff = OfficeStaff(user=user, current_practice=practice)
		staff.save()
		staff.practices.add(practice)

		manager = Office_Manager(user=staff, practice=practice, manager_role=manager_role)
		manager.save()

		# TESTING_KMS_INTEGRATION
		create_default_keys(user, userform.cleaned_data['password1'])

		# Remove the invitation.
		invite.delete(createdUser=user, createdPractice=practice, send_notice=False)
		msg = render_to_string('MHLSignup/practice_notification_email.txt',
			{'practice_name': practice.practice_name,
			'practice_id': practice.id,
			'timestamp': datetime.datetime.now().strftime("%I:%M %m/%d/%Y")})
		send_mail("new practice created", msg, '*****@*****.**', ["*****@*****.**"])
		return HttpResponseRedirect(self.redirect_url)
Ejemplo n.º 24
0
    def test_rejectAssociation(self):
        #user is a manager
        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=2)
        manager.save()

        #invalid assoc id
        assocID = {'assoc_id': 'a'}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.rejectAssociation'),
            data=assocID)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(
            msg['err'], _('The data is error. Please refresh the page again.'))

        #valid assoc id
        to_user = create_user(
            'p2',
            'lin2',
            'xing2',
            'demo',
            '',
            '',
            '',
            '',
        )
        provider = Provider(username='******',
                            first_name='first',
                            last_name="last",
                            email='*****@*****.**',
                            user=self.user,
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        pend = Pending_Association(from_user=self.user,
                                   to_user=to_user,
                                   practice_location=self.practice,
                                   created_time=datetime.datetime.now())
        pend.save()
        assocID = {'assoc_id': pend.id}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.rejectAssociation'),
            data=assocID)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg, 'OK')
        self.assertEqual(
            Log_Association.objects.get(association_id=pend.id).action, 'REJ')
        self.assertEqual(Pending_Association.objects.count(), 0)
Ejemplo n.º 25
0
def member_staff_create(request):
	context = get_context_for_organization(request)
	current_practice = request.org
	if request.method == 'POST':
		staff_form = CreateOfficeStaffForm(request.POST, current_practice=current_practice)
		mhluser_form = CreateMHLUserForm(request.POST, request.FILES)

		if staff_form.is_valid() and mhluser_form.is_valid():
			mhluser = mhluser_form.save(commit=False)
			mhluser.is_active = 0
			mhluser.address1 = current_practice.practice_address1
			mhluser.address2 = current_practice.practice_address2
			mhluser.city = current_practice.practice_city
			mhluser.state = current_practice.practice_state
			mhluser.zip = current_practice.practice_zip
			mhluser.lat = current_practice.practice_lat
			mhluser.longit = current_practice.practice_longit
			mhluser.save()

			staff = staff_form.save(commit=False)
			staff.user = mhluser
			staff.current_practice = current_practice
			staff.save()

			staff.practices.add(current_practice)
			staff.save()

			staff_type = int(staff_form.cleaned_data['staff_type'])

			if USER_TYPE_OFFICE_MANAGER == staff_type:
				manager = Office_Manager(user=staff, practice=current_practice)
				manager.save()
			if USER_TYPE_NURSE == staff_type:
				nurse = Nurse(user=staff)
				nurse.save()
			elif USER_TYPE_DIETICIAN == staff_type:
				dietician = Dietician(user=staff)
				dietician.save()

			# TESTING_KMS_INTEGRATION
			create_default_keys(mhluser)

			sendAccountActiveCode(request, USER_TYPE_OFFICE_STAFF, 
				current_practice, request.session["MHL_Users"]["MHLUser"])
		else:
			context['user_form'] = mhluser_form
			context['staff_form'] = staff_form
			return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
	context['user_form'] = CreateMHLUserForm()

	staff_form = CreateOfficeStaffForm(current_practice=current_practice)
	context['staff_form'] = staff_form

	return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
Ejemplo n.º 26
0
class GetSubTypesICanUseTest(TestCase):
	org_type = None
	admin = None
	manager = None
	organization = None

	def setUp(self):
		clean_db_datas()

		OrganizationType.objects.all().delete()
		org_setting = OrganizationSetting()
		org_setting.save()
		self.org_type = OrganizationType(name="Test Org Type1", 
			organization_setting=org_setting, is_public=True)
		# TODO: issue 2030, reserved id's is a hazardous approach, the UT's 
		# were working with SQLlite but not with MySQL, DB engines recycle
		# id's differently and we should not rely on reserved id fields.  This 
		# should be addressed in a separate Redmine as model changes may occur.
		self.org_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
		self.org_type.save()

		self.organization = create_organization()
		self.organization = PracticeLocation(
			practice_name=get_random_username(),
			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)
		self.organization.save()

		self.admin = create_user('admin', 'Morris', 'Kelly', 'demo', uklass=Administrator)
		staff = create_user('practicemgr1', 'Practice', 'Mgr', 'demo', uklass=OfficeStaff)
		staff.practices.add(self.organization)
		staff.save()

		self.manager = Office_Manager(user=staff, practice=self.organization, manager_role=1)
		self.manager.save()

	def test_get_sub_types_I_can_use_empty(self):
		self.assertEqual(0, len(get_sub_types_by_typeid(self.org_type.id)))

	def test_get_sub_types_I_can_use(self):
		create_multiple_organization_types(self.org_type, num=10)
		self.assertEqual(10, len(get_sub_types_by_typeid(self.org_type.id)))

		create_multiple_organization_types(self.org_type, num=10, is_public=False)
		self.assertEqual(10, len(get_sub_types_by_typeid(self.org_type.id)))
		self.assertEqual(0, len(get_sub_types_by_typeid(self.org_type.id, is_public=True)))

	def tearDown(self):
		pass
Ejemplo n.º 27
0
    def test_getMembers(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #0 member found
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        self.call_group.id,
                    )))
        self.assertEqual(response.status_code, 200)

        #1 member found
        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        member = CallGroupMember(call_group=self.call_group,
                                 member=provider,
                                 alt_provider=1)
        member.save()
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        self.call_group.id,
                    )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 1)
        self.assertEqual(msg[0][0], provider.id)

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        call_group2.id,
                    )))
        self.assertEqual(response.status_code, 403)
Ejemplo n.º 28
0
    def test_rulesCheck(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        checkString = 'Ca69J2X6l8'
        #init a schecule event
        startDate = datetime.datetime.now() + datetime.timedelta(days=2)
        endDate = datetime.datetime.now() + datetime.timedelta(days=3)
        event = EventEntry(creator=self.user,
                           oncallPerson=provider,
                           callGroup=self.call_group,
                           startDate=startDate,
                           endDate=endDate,
                           title='test event',
                           oncallLevel='0',
                           eventStatus=1,
                           checkString=checkString)
        event.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.rulesCheck',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'DateEntry.html')

        #post method
        data = {
            'fromDate': '2012-12-10 12:00:00',
            'toDate': '2012-12-14 12:00:00'
        }
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.rulesCheck',
            args=(self.call_group.id, )),
                                    data=data)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg[0].find('warning hole in coverage '), 0)
Ejemplo n.º 29
0
	def test_display_scheduler_emptydata(self):
		dataEmpty = {}
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()

		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views.display_scheduler', 
			args=(self.call_group.id,)), data=dataEmpty)
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'schedule.html')
		self.assertEqual(-1, response.content.find('fc-event-inner'))  # event tag
Ejemplo n.º 30
0
	def test_isMultiCallGroupManager(self):
		#init practice and call group
		call_group = CallGroup(description='test', team='team')
		call_group.save()
		
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		practice.call_groups.add(call_group)
		
		user = create_user('user1', 'us', 'er', 'demo')
		
		#only mhluser call method
		result = isMultiCallGroupManager(user, practice.id, call_group.id)
		self.assertEqual(result, False)
		
		#staff call method
		staff = OfficeStaff(user=user)
		staff.save()
		result = isMultiCallGroupManager(user, call_group.id, practice.id)
		self.assertEqual(result, False)
		
		practice2 = PracticeLocation(practice_name='test2',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice2.save()
		practice2.call_groups.add(call_group)
		
		#manager call method
		staff.practices.add(practice)
		staff.save()
		manager = Office_Manager(user=staff, practice=practice, manager_role=1)
		manager.save()
		result = isMultiCallGroupManager(user, call_group.id, practice.id)
		self.assertEqual(result, True)
		
		#manager with specialty call method
		specialty_name = 'Specialty A'
		specialty1 = Specialty()
		specialty1.name = specialty_name
		specialty1.practice_location = practice
		specialty1.number_selection = 3
		specialty1.save()
		specialty1.call_groups.add(call_group)
		
		manager2 = Office_Manager(user=staff, practice=practice2, manager_role=1)
		manager2.save()
		
		result = isMultiCallGroupManager(user, call_group.id, practice.id)
		self.assertEqual(result, True)
Ejemplo n.º 31
0
    def test_staffHome(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=2)
        manager.save()

        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.staffHome'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'Staff/staffHome.html')
Ejemplo n.º 32
0
	def test_display_scheduler_session(self):
		dataEmpty = {}
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()

		self.client.session[SessionHelper.CURRENT_CALLGROUP_ID] = self.group.id
		self.client.session.save()
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.display_scheduler', args=(self.practice.id, 0)), data=dataEmpty)
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'schedule_multicallgroup.html')
Ejemplo n.º 33
0
	def test_display_scheduler_403_group(self):
		dataEmpty = {}
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()

		group = CallGroup(description='test', team='team')
		group.save()
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.display_scheduler', 
				args=(self.practice.id, group.id)), data=dataEmpty)
		self.assertEqual(response.status_code, 403)
Ejemplo n.º 34
0
    def test_practice_profile_edit_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.get(
            reverse('MHLogin.MHLPractices.views.practice_profile_edit'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'Profile/practice_profile_edit.html')
Ejemplo n.º 35
0
	def test_associate_manager(self):
		staff2 = OfficeStaff(user=self.user, current_practice=self.practice)
		staff2.save()
		manager = Office_Manager(user=staff2, practice=self.practice, manager_role=2)
		manager.save()
		self.user = manager
		self.user.save()
		staff2Data = {'username': self.user.user.user.username,
			'password': '******',
			'device_id': 'e2c73b2b28f7466da855005ef48cdeaa',
			'app_version': '1.00.22',
			'platform': 'iPad', }
		response = self.client.post(reverse('MHLogin.apps.smartphone.v1.views_device.associate'), 
								data=staff2Data)
		self.assertEqual(response.status_code, 200)
Ejemplo n.º 36
0
	def test_pratice_info(self):
		self.client.post('/login/', {'username': self.user.username,
			'password': '******'})
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		response = self.client.get(reverse('MHLogin.DoctorCom.views.practice_info'))
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'MHLUsers/practice_info.html')
		self.client.logout()
Ejemplo n.º 37
0
    def setUpClass(cls):
        clean_db_datas()
        cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
        cls.user1 = create_user('practicemgr11', 'y', 'p', 'demo')

        cls.broker = create_user("broker1",
                                 "bro",
                                 "1",
                                 "demo",
                                 "123 Main St.",
                                 "Phoenix",
                                 "AZ",
                                 uklass=Broker)

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice1 = PracticeLocation(
            practice_name='test1',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice1.save()

        OrganizationRelationship.objects.create(organization=practice,\
         parent=practice1, create_time=int(time.time()), billing_flag=True)

        cls.practice = practice
        staff = OfficeStaff()
        staff.user = cls.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.current_practice = practice
        staff.save()
        staff.practices.add(practice)

        cls.provider = Provider(user=cls.user1,
                                office_lat=0.0,
                                office_longit=0.0,
                                current_practice=practice)
        cls.provider.mdcom_phone = '5948949899'
        cls.provider.save()
        #
        mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
        mgr.save()
Ejemplo n.º 38
0
	def testGetDComNumber(self):
		user = create_user(get_random_username(), "tian", "thj", "demo", "555 Bryant St.",
								"Palo Alto", "CA", "", uklass=OfficeStaff)
		user.mdcom_phone = '9001234123'
		user.save()
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		mgr = Office_Manager(user=user, practice=practice, manager_role=2)
		mgr.save()
		response = self.client.get(reverse\
				('MHLogin.api.v1.views_account.getDComNumber'), **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
Ejemplo n.º 39
0
    def test_getViewInfo(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #post method
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #get method without session
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(call_group2.id, )))
        self.assertEqual(response.status_code, 403)

        #get method with session---TODO
        view = '{"name":"agendaWeek","start":"2012-12-16 00:00:00","end":"2012-12-23 00:00:00"}'
        self.client.session[SessionHelper.SCHEDULE_LASTVIEW] = view
        self.client.session.save()
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')
Ejemplo n.º 40
0
	def test_display_scheduler_nopractice(self):
		dataEmpty = {}
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()
		practice2 = PracticeLocation(practice_name='test2',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice2.save()
		manager.practice = practice2
		manager.save()
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.display_scheduler', args=(practice2.id, 0)), data=dataEmpty)
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'error_multicallgroup.html')
Ejemplo n.º 41
0
    def test_practice_main_view(self):
        #403
        #		response = self.client.post(reverse('MHLogin.MHLPractices.views.practice_main_view'))
        #		self.assertEqual(response.status_code, 403)

        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)

        #staff no current practice
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.practice_main_view'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'dashboard_office_staff.html')

        #staff and current practice
        staff.current_practice = self.practice
        staff.save()
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.practice_main_view'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'dashboard_office_staff.html')

        #manger
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=2)
        manager.save()

        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.practice_main_view'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'dashboard_office_manager.html')

        #manager and current site
        site = Site(name='test site',
                    address1='test address',
                    lat='0.4',
                    longit='4.1')
        staff.current_site = site
        staff.save()
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views.practice_main_view'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'dashboard_office_manager.html')
Ejemplo n.º 42
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user(get_random_username(), 'lin', 'xing', 'demo')
		cls.user1 = create_user(get_random_username(), 'y', 'p', 'demo')
		cls.user2 = create_user(get_random_username(), 'y', 'p', 'demo')
		cls.to_user = create_user(get_random_username(), "tian", "thj", "demo", "555 Bryant St.",
								"Palo Alto", "CA", "")

		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice1.save()
		
		OrganizationRelationship.objects.create(organization=practice,\
				parent=practice1,create_time=int(time.time()),billing_flag=True)
		cls.practice = practice
		cls.practice1 = practice1
		
		assoc = Pending_Association()
		assoc.from_user = cls.user1
		assoc.to_user = cls.to_user
		assoc.practice_location = practice
		assoc.created_time = datetime.datetime(2013, 5, 14, 12, 30)
		assoc.resent_time = datetime.datetime(2013, 5, 14, 13, 30)
		assoc.save()
		cls.assoc = assoc
		
		provider = Provider(user=cls.to_user, office_lat=0.0, office_longit=0.0, current_practice = practice)
		provider.save()
		cls.provider = provider
		
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
Ejemplo n.º 43
0
    def test_display_scheduler_emptydata(self):
        dataEmpty = {}
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=2)
        manager.save()

        response = self.client.get(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.display_scheduler',
            args=(self.call_group.id, )),
                                   data=dataEmpty)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'schedule.html')
        self.assertEqual(-1,
                         response.content.find('fc-event-inner'))  # event tag
Ejemplo n.º 44
0
	def test_get_orgs_I_can_manage_user(self):
		user = create_user('yangpeng','yang','peng','demo')
		org_setting = OrganizationSetting()
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", \
				organization_setting=org_setting, is_public=True)
		org_type.save()
		staff = OfficeStaff()
		staff.user = user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = self.organization
		staff.save()
		staff.practices.add(self.organization)
		mgr = Office_Manager(user=staff, practice=self.organization, manager_role=2)
		mgr.save()
		get_orgs_I_can_manage(mgr.id,parent_id=self.parent_organization.id,\
				org_type_id=org_type.id,clear_no_type_org=True)
Ejemplo n.º 45
0
	def test_addPrvoderIn(self):
		prov = Provider(username='******', first_name='tes', last_name="meister", email='*****@*****.**',
					office_lat=0.0, office_longit=0.0)
		prov.save()
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		data = {'to_user': prov.id}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.addPrvoderIn', 
			args=(self.practice.id, self.group.id)), data=data)
		msg = json.loads(response.content)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(0, msg['err'].find('Congratulations'))
Ejemplo n.º 46
0
	def test_rulesCheck(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		staff.current_practice = self.practice
		staff.save()
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		provider = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider.save()
		checkString = 'Ca69J2X6l8'
		#init a schecule event
		timenow = datetime.datetime.now()
		startDate = timenow + datetime.timedelta(days=2)
		endDate = timenow + datetime.timedelta(days=3)
		event = EventEntry(creator=self.user,
						oncallPerson=provider,
						callGroup=self.call_group,
						startDate=startDate,
						endDate=endDate,
						title='test event',
						oncallLevel='0',
						eventStatus=1,
						checkString=checkString
						)
		event.save()

		#get method
		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.rulesCheck', 
			args=(self.practice.id, self.call_group.id)))
		self.assertEqual(response.status_code, 200)
		self.assertTemplateUsed(response, 'DateEntry.html')

		#post method
		data = {'fromDate': '2012-12-10 12:00:00', 'toDate': '2012-12-14 12:00:00'}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.rulesCheck', 
			args=(self.practice.id, self.call_group.id)), data=data)
		self.assertEqual(response.status_code, 200)
		msg = json.loads(response.content)
		start = datetime.datetime.now()
		end = start + datetime.timedelta(days=14)
		self.assertTrue('warning hole in coverage' in msg[0])
Ejemplo n.º 47
0
    def setUpClass(cls):
        clean_db_datas()
        cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
        org_setting = OrganizationSetting()
        org_setting.save()
        org_type = OrganizationType(name="Test Org Type",
                                    organization_setting=org_setting,
                                    is_public=True)
        org_type.save()
        cls.org_type = org_type
        sub_types = create_multiple_organization_types(org_type)
        cls.sub_types = sub_types

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
        )
        practice.save()
        practice1 = PracticeLocation(
            practice_name='test1',
            practice_longit='0.1',
            practice_lat='0.0',
            organization_type=org_type,
        )
        practice1.save()
        OrganizationRelationship.objects.create(organization=practice,
                                                parent=practice1,
                                                create_time=int(time.time()),
                                                billing_flag=True)
        cls.practice = practice
        cls.practice1 = practice1

        staff = OfficeStaff()
        staff.user = cls.user
        staff.office_lat = 0.0
        staff.office_longit = 0.0
        staff.current_practice = practice
        staff.save()
        staff.practices.add(practice)

        mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
        mgr.save()
Ejemplo n.º 48
0
    def test_user_info(self):
        request = generateHttpRequest()

        #not find any provider match
        result = user_info(request, -123)
        self.assertEqual(result.status_code, 400)
        msg = json.loads(result.content)
        self.assertEqual(msg['errno'], 'PF001')

        #provider call this method
        result = user_info(request, request.user.id)
        self.assertEqual(result.status_code, 200)

        #physician call this method
        phy = Physician(user=request.provider)
        phy.save()
        result = user_info(request, request.user.id)
        self.assertEqual(result.status_code, 200)

        #staff call this method
        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 101
        assn.save(request)

        staff = OfficeStaff(user=request.user)
        staff.save()
        result = user_info(request, request.user.id)
        self.assertEqual(result.status_code, 200)

        #staff with current practice
        organization_type = create_org_type()
        practice = ct_practice('name', organization_type)
        staff.current_practice = practice
        staff.save()
        result = user_info(request, request.user.id)
        self.assertEqual(result.status_code, 200)

        #manager call this method
        manager = Office_Manager(user=staff, practice=practice, manager_role=2)
        manager.save()
        result = user_info(request, request.user.id)
        self.assertEqual(result.status_code, 200)
Ejemplo n.º 49
0
    def test_cancelExistInvitation(self):
        #user is a manager
        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=2)
        manager.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLPractices.views_ajax.cancelExistInvitation'))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg[1], _('A server error has occured.'))

        email = '*****@*****.**'
        user_type = 1
        invite = Invitation(sender=self.user,
                            recipient=email,
                            assignPractice=self.practice,
                            userType=user_type)
        invite.save()

        #there is no invite find
        data = {'email': '*****@*****.**', 'type': '0'}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.cancelExistInvitation'),
            data=data)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg[1], _('A server error has occured.'))

        data = {'email': email, 'type': user_type}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.cancelExistInvitation'),
            data=data)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg[0], 'ok')
        self.assertEqual(Invitation.objects.count(), 0)
Ejemplo n.º 50
0
	def test_user_info(self):
		request = generateHttpRequest()

		#not find any provider match
		result = user_info(request, -123)
		self.assertEqual(result.status_code, 400)
		msg = json.loads(result.content)
		self.assertEqual(msg['errno'], 'PF001')

		#provider call this method
		result = user_info(request, request.user.id)
		self.assertEqual(result.status_code, 200)

		#physician call this method
		phy = Physician(user=request.provider)
		phy.save()
		result = user_info(request, request.user.id)
		self.assertEqual(result.status_code, 200)

		#staff call this method
		assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
		assn.user_type = 101
		assn.save(request)

		staff = OfficeStaff(user=request.user)
		staff.save()
		result = user_info(request, request.user.id)
		self.assertEqual(result.status_code, 200)

		#staff with current practice
		organization_type = create_org_type()
		practice = ct_practice('name', organization_type)
		staff.current_practice = practice
		staff.save()
		result = user_info(request, request.user.id)
		self.assertEqual(result.status_code, 200)

		#manager call this method
		manager = Office_Manager(user=staff, practice=practice, manager_role=2)
		manager.save()
		result = user_info(request, request.user.id)
		self.assertEqual(result.status_code, 200)
Ejemplo n.º 51
0
    def test_addAssociation(self):
        #user is a manager
        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=2)
        manager.save()

        #provider id
        user = create_user(
            'p',
            'lin2',
            'xing2',
            'demo',
            '',
            '',
            '',
            '',
        )
        provider = Provider(username='******',
                            first_name='first',
                            last_name="last",
                            email='*****@*****.**',
                            user=user,
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()

        data = {'prov_id': provider.user.id, 'userType': 1}
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.addAssociation'), data)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg[0], 'ok')
        self.assertEqual(Pending_Association.objects.count(), 1)
        self.assertEqual(
            Pending_Association.objects.get(to_user=provider.user).from_user,
            self.user)
        self.assertEqual(Log_Association.objects.count(), 1)
Ejemplo n.º 52
0
 def test_associate_manager(self):
     staff2 = OfficeStaff(user=self.user, current_practice=self.practice)
     staff2.save()
     manager = Office_Manager(user=staff2,
                              practice=self.practice,
                              manager_role=2)
     manager.save()
     self.user = manager
     self.user.save()
     staff2Data = {
         'username': self.user.user.user.username,
         'password': '******',
         'device_id': 'e2c73b2b28f7466da855005ef48cdeaa',
         'app_version': '1.00.22',
         'platform': 'iPad',
     }
     response = self.client.post(
         reverse('MHLogin.apps.smartphone.v1.views_device.associate'),
         data=staff2Data)
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 53
0
	def test_display_scheduler_namelength(self):
		dataEmpty = {}
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=2)
		manager.save()

		specialty_name_80 = 'abcdefghjyabcdefghjyabcdefghjyabcdefghjyabcdefghjyabcdefghjyabcdefghjyabcdefghjy123456'
		specialty2 = Specialty()
		specialty2.name = specialty_name_80
		specialty2.practice_location = self.practice
		specialty2.number_selection = 3
		specialty2.save()
		specialty2.call_groups.add(self.group)

		response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.display_scheduler', 
			args=(self.practice.id, self.group.id)), data=dataEmpty)
		self.assertEqual(response.status_code, 200)
		self.assertGreater(response.content.find(specialty_name_80[0:80]), 0)
Ejemplo n.º 54
0
 def test_get_orgs_I_can_manage_user(self):
     user = create_user('yangpeng', 'yang', 'peng', 'demo')
     org_setting = OrganizationSetting()
     org_setting.save()
     org_type = OrganizationType(name="Test Org Type", \
       organization_setting=org_setting, is_public=True)
     org_type.save()
     staff = OfficeStaff()
     staff.user = user
     staff.office_lat = 0.0
     staff.office_longit = 0.0
     staff.current_practice = self.organization
     staff.save()
     staff.practices.add(self.organization)
     mgr = Office_Manager(user=staff,
                          practice=self.organization,
                          manager_role=2)
     mgr.save()
     get_orgs_I_can_manage(mgr.id,parent_id=self.parent_organization.id,\
       org_type_id=org_type.id,clear_no_type_org=True)
Ejemplo n.º 55
0
	def setUpClass(cls):
		clean_db_datas()
		cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
		cls.admin = create_user("sduper", "super", "duper", "demo", 
							"Ocean Avenue", "Carmel", "CA", "93921", uklass=Administrator)
		cls.admin.save()
		org_setting = OrganizationSetting(can_have_manager=True,\
						can_have_nurse=True,can_have_dietician=True)
		org_setting.save()
		org_type = OrganizationType(name="Test Org Type", \
						organization_setting=org_setting, is_public=True)
		org_type.save()
		cls.org_type = org_type
		cls.org_setting = org_setting
		
		practice = PracticeLocation(practice_name='test',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting =org_setting,
								organization_type = org_type)
		practice.save()
		practice1 = PracticeLocation(practice_name='test1',
								practice_longit='0.1',
								practice_lat='0.0',
								organization_setting =org_setting,
								organization_type = org_type)
		practice1.save()
		cls.practice = practice
		cls.practice1 = practice1
		
		staff = OfficeStaff()
		staff.user = cls.user
		staff.office_lat = 0.0
		staff.office_longit = 0.0
		staff.current_practice = practice
		staff.save()
		staff.practices.add(practice)
		cls.staff = staff
		
		mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
		mgr.save()
Ejemplo n.º 56
0
    def test_saveViewInfo(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
                    args=(call_group2.id, )))
        self.assertEqual(response.status_code, 403)

        #post method without session
        view = {
            'view':
            '{"name":"month", "start":"2012-12-01 00:00:00", "end":"2013-01-01 00:00:00"}'
        }
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
            args=(self.call_group.id, )),
                                    data=view)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], view['view'])
Ejemplo n.º 57
0
    def test_practice_staff(self):
        request = generateHttpRequest()
        staff = OfficeStaff(user=request.user)
        staff.save()
        assn = SmartPhoneAssn.all_objects.get(
            device_id=request.REQUEST['DCOM_DEVICE_ID'])
        assn.user_type = 101
        assn.save(request)

        #staff and has no current practice
        result = practice_staff(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 0)

        organization_type = create_org_type()
        practice = ct_practice('test', organization_type)
        staff.current_practice = practice

        #staff has current practice but has 0 staff find
        result = practice_staff(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 0)

        #staff has current practice but has 1 staff find
        staff.current_practice = practice
        staff.save()
        staff.practices.add(practice)
        manager = Office_Manager(user=staff, practice=practice, manager_role=2)
        manager.save()
        result = practice_staff(request)
        self.assertEqual(result.status_code, 200)
        msg = json.loads(result.content)
        self.assertEqual(len(msg['data']['users']), 1)

        #return_python == True
        result = practice_staff(request, True)
        msg = result['data']['users']
        self.assertEqual(len(msg), 1)
Ejemplo n.º 58
0
    def test_removeProvider(self):
        #user is a manager
        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=2)
        manager.save()

        #practice has no call group
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.removeProvider'))
        self.assertEqual(response.status_code, 200)

        #practice has call group
        self.practice.call_group = self.call_group
        self.practice.save()
        response = self.client.post(
            reverse('MHLogin.MHLPractices.views_ajax.removeProvider'))
        self.assertEqual(response.status_code, 200)