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"
Esempio n. 2
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'})