def test_delete_system_recipient(self):
		state = mixer.blend('base.State', name = 'Active')
		recipient = mixer.blend('core.User', state = state)
		data = RecipientAdministrator.delete_recipient(system_recipient_id=recipient.id)
		data2 = RecipientAdministrator.delete_recipient(system_recipient_id = '')
		assert data.get('code') == '800.200.001'
		assert data2.get('code') == '800.400.002'
	def test_delete_system_recipient(self):
		state = mixer.blend('base.State', name = 'Active')
		recipient = mixer.blend('core.User', state = state)
		system = mixer.blend('core.System', state = state)
		system_recipient = mixer.blend('core.SystemRecipient', recipient = recipient)
		data = RecipientAdministrator.delete_system_recipient(system_recipient_id = system_recipient.id)
		data2 = RecipientAdministrator.delete_system_recipient(system_recipient_id = system.id)
		assert data.get('code') == '800.200.001', "should update system recipients"
		assert data2.get(
			'code') == '800.400.002', "Should return an error showing unable to update system recipient"
	def test_update_system_recipients(self):
		state = mixer.blend('base.State', name = 'Active')
		escalation_level = mixer.blend('base.EscalationLevel', state = state)
		recipient = mixer.blend('core.User', state = state)
		notification = mixer.blend('core.Notification', state=state)
		system = mixer.blend('core.System', state = state)
		system_recipient = mixer.blend('core.SystemRecipient', recipient=recipient)
		data = RecipientAdministrator.update_system_recipient(
			recipient_id = recipient.id,
			escalations = [{"NotificationType": notification.id, "EscalationLevel":escalation_level.id}],
		)
		data2 = RecipientAdministrator.update_system_recipient(
			recipient_id = system.id,
			escalations = [{"NotificationTYpe": notification.id, "EscalationLevel": escalation_level.id}],
		)
		assert data.get('code') == '800.200.001', "should update system recipients"
		assert data2.get('code') == '800.400.001', "Should return an error showing unable to update system recipient"
	def test_create_system_recipients(self):
		state = mixer.blend('base.State', name = 'Active')
		escalation_level = mixer.blend('base.EscalationLevel', state = state)
		recipient = mixer.blend('core.User', state = state)
		notification = mixer.blend('core.Notification', state=state)
		system = mixer.blend('core.System', state = state)
		data = RecipientAdministrator.create_system_recipient(
			system_id = system.id,
			escalations = [{"NotificationType": notification.id, "EscalationLevel": escalation_level.id}],
			user_id = recipient.id
		)
		data2 = RecipientAdministrator.create_system_recipient(
			system_id = system.id,
			escalations = [{"NotificationType": notification.id, "EscalationLevel": escalation_level.id}],
			user_id = recipient.id
		)
		assert data.get('code') == '800.200.001', "should create system recipients"
		assert data2.get('code') == '800.400.001', "Should return Error indicating unable to create system recipient "
Exemple #5
0
def delete_system_recipient(request):
	"""
	Delete a specific Recipient
	@param request:The Django WSGI Request to process
	@return:dict
	"""
	try:
		data = get_request_data(request)
		recipient = RecipientAdministrator.delete_system_recipient(
			system_recipient_id = data.get('system_recipient_id')
		)
		return JsonResponse(recipient)

	except Exception as ex:
		lgr.exception('recipient get Exception: %s' % ex)
	return JsonResponse({'code': '800.500.001'})
Exemple #6
0
def get_system_recipient(request):
	"""
	Get a specific system recipient
	@param request: The Django WSGI Request to process
	@type request: WSGIRequest
	@return: The requested recipient or a status code indicating errors if any.
	@rtype: dict
	"""
	try:
		data = get_request_data(request)
		recipient = RecipientAdministrator.get_system_recipient(
			user_id = data.get('recipient_id'), system_id = data.get('system_id'))
		return JsonResponse(recipient)
	except Exception as ex:
		lgr.exception('Look up data get Exception: %s' % ex)
	return JsonResponse({'code': '800.500.001'})
Exemple #7
0
def update_system_recipient(request):
	"""
	Updates an existing incident's priority, resolution status or user assignment
	@param request: The Django WSGI Request to process
	@type request: WSGIRequest
	@return: A response code to indicate successful recipient update or otherwise
	@rtype: dict
	"""
	try:
		data = get_request_data(request)
		updated_recipient = RecipientAdministrator.update_system_recipient(
			recipient_id = data.get('recipient_id'), escalations = data.get('escalations')
		)
		return JsonResponse(updated_recipient)
	except Exception as ex:
		lgr.exception('Recipient update Exception: %s' % ex)
	return JsonResponse({'code': '800.500.001'})
Exemple #8
0
def create_recipient(request):
	"""
	Creates endpoints from users
	@param request: The Django WSGI Request to process
	@type request: WSGIRequest
	@return: A response code to indicate successful recipient creation or otherwise
	@rtype: dict
	"""
	try:
		data = get_request_data(request)
		recipient = RecipientAdministrator.create_recipient(
			state_id = data.get('stateId'), phone_number = data.get('phoneNumber'), user_id = data.get('userId')
		)
		return JsonResponse(recipient)
	except Exception as ex:
		lgr.exception('Recipient creation Exception: %s' % ex)
	return JsonResponse({'code': '800.500.001'})