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 "
예제 #2
0
def create_system_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)
		system_recipient = RecipientAdministrator.create_system_recipient(
			system_id = data.get('system_id'), user_id = data.get('Recipient'),
			escalations = data.get('escalations')
		)
		return JsonResponse(system_recipient)
	except Exception as ex:
		lgr.exception('Recipient creation Exception: %s' % ex)
	return JsonResponse({'code': '800.500.001'})