Beispiel #1
0
def test_ticket_actions_decrease_priority():
    rt_object = RTApiMock()
    rt_object.set_return([
        u'id: ticket/887677',
        u'owner: [email protected]',
        u'subject: create rt dashboard',
        u'status: open',
        u'priority: 26',
        u'cf.{servico}: csc-gsiic',
        u'cf.{is - informatica e sistemas}: dir-inbox',
    ])
    ticket_actions(rt_object, '887677', 'decrease_priority', '*****@*****.**',
                   '*****@*****.**')
    assert rt_object.uri == 'ticket/887677/edit'
    assert rt_object.data == {'content': 'priority: 25\n'}
Beispiel #2
0
def test_ticket_actions_forward_new():
    rt_object = RTApiMock()
    rt_object.set_return([
        u'id: ticket/887677',
        u'owner: [email protected]',
        u'subject: create rt dashboard',
        u'status: new',
        u'priority: 26',
        u'cf.{servico}: csc-gsiic',
        u'cf.{is - informatica e sistemas}: dir-inbox',
        u'starts: ' + str(ctime(time())),
        u'timeworked: 10 minutes',
    ])
    ticket_actions(rt_object, '887677', 'forward', '*****@*****.**', '*****@*****.**')
    assert rt_object.uri == 'ticket/887677/edit'
    assert 'status: open\nstarts: ' in rt_object.data['content']
Beispiel #3
0
def test_ticket_actions_unset_urgent():
    rt_object = RTApiMock()
    rt_object.set_return(
        [
                u'id: ticket/887677',
                u'owner: [email protected]',
                u'subject: create rt dashboard',
                u'status: open',
                u'priority: 26',
                u'cf.{servico}: csc-gsiic',
                u'cf.{is - informatica e sistemas}: dir-inbox',
        ]
    )
    ticket_actions(rt_object, '887677', 'unset_urgent', '*****@*****.**', '*****@*****.**')
    assert rt_object.uri == 'ticket/887677/edit'
    assert rt_object.data == {
        'content': 'cf.{DITIC-Urgent}: \n',
    }
Beispiel #4
0
def test_ticket_actions_stalled_open():
    rt_object = RTApiMock()
    rt_object.set_return(
        [
                u'id: ticket/887677',
                u'owner: [email protected]',
                u'subject: create rt dashboard',
                u'status: open',
                u'priority: 26',
                u'cf.{servico}: csc-gsiic',
                u'cf.{is - informatica e sistemas}: dir-inbox',
                u'starts: '+str(ctime(time())),
                u'timeworked: 10 minutes',
        ]
    )
    ticket_actions(rt_object, '887677', 'stalled', '*****@*****.**', '*****@*****.**')
    assert rt_object.uri == 'ticket/887677/edit'
    assert 'status: stalled\nstarts: 0\ntimeworked: 10.' in rt_object.data['content']
Beispiel #5
0
def ticketAction2(ticket_id, action):

    start_time = time()

    result = create_default_result()
    result2 = create_default_result()

    if request.query.o == '' or not user_auth.check_id(request.query.o):
        result.update({'message': ''})
        return template('auth', result)

    # Apply the action to the ticket
    result.update(
        ticket_actions(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), ticket_id,
            action, request.query.email,
            user_auth.get_email_from_id(request.query.o)))

    # Update table for this user
    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)),
            request.query.email))

    result2.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), "inbox"))

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': request.query.email})
    result.update({'username_id': request.query.o})

    # Is there any URGENT ticket?
    result.update({'urgent': get_urgent_tickets(rt_object)})

    result.update({'summary': get_summary_info()})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    result2.update({'urgent': get_urgent_tickets(rt_object)})

    result2.update({'summary': get_summary_info()})

    result2.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    if request.query.email == 'inbox' or request.query.email == 'unknown':
        return template('ticket_list', result)
    else:
        return template('detail', result, tickets2=result2)
Beispiel #6
0
def test_ticket_actions_unknown_option():
    rt_object = RTApiMock()
    rt_object.set_return([
        u'id: ticket/887677',
        u'owner: [email protected]',
        u'subject: create rt dashboard',
        u'status: open',
        u'priority: 26',
        u'cf.{servico}: csc-gsiic',
        u'cf.{is - informatica e sistemas}: dir-inbox',
    ])
    result = ticket_actions(rt_object, '887677', 'not_known', '*****@*****.**',
                            '*****@*****.**')
    assert rt_object.data == {'query': 'id = "887677"', 'format': 'l'}
    assert rt_object.uri == '/search/ticket'
    assert result == {
        'action_result': 'Still working on it... sorry for the inconvenience!'
    }
Beispiel #7
0
def archive_tickets_server(email):

    start_time = time()

    result = create_default_result()

    dictResultRes = user_get_resolved_tickets(rt_object, email)
    listTickets = getTicketsIds(dictResultRes)

    if request.query.o == '' or not user_auth.check_id(request.query.o):
        result.update({'message': ''})
        return template('auth', result)

    for i in range(len(listTickets)):
        # Apply the action to the ticket
        result.update(ticket_actions(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)
            ),
            listTickets[i],
            'forward',
            request.query.email, user_auth.get_email_from_id(request.query.o)
        ))

    # Update table for this user
    result.update(user_tickets_details(
        user_auth.get_rt_object_from_email(
            user_auth.get_email_from_id(request.query.o)
        ), request.query.email))

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': request.query.email})
    result.update({'username_id': request.query.o})

    # Is there any URGENT ticket?
    result.update({'urgent': get_urgent_tickets(rt_object)})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})
    result.update({'summary:': get_summary_info()})

    os.system('update_statistics')
    os.system("generate_summary_file")

    return template('detail', result)
Beispiel #8
0
def ticket_action2(ticket_id, action):
	
	start_time = time()

	result = create_default_result()
	if request.query.o == '' or not user_auth.check_id(request.query.o):
		result.update({'message': ''})
		return template('auth', result)

	# Apply the action to the ticket
	result.update(ticket_actions(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		),
		ticket_id,
		action,
		request.query.email, user_auth.get_email_from_id(request.query.o)
	))

	# Update table for this user
	result.update(user_tickets_details(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		), request.query.email))

	result.update({'username': user_auth.get_email_from_id(request.query.o)})
	result.update({'email': request.query.email})
	result.update({'username_id': request.query.o})

	# Is there any URGENT ticket?
	result.update({'urgent': get_urgent_tickets(rt_object)})

	result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

	#update all

	if request.query.email == 'dir' or request.query.email == 'dir-inbox' or request.query.email == 'unknown':
		return template('ticket_list', result)

	elif request.query.email == 'history':
		return template('history', result)

	else:
		return template('detail', result)
Beispiel #9
0
def archive_ticket(ticket_id,action):
	start_time = time()

	result = create_default_result()
	if request.query.o == '' or not user_auth.check_id(request.query.o):
		result.update({'message': ''})
		return template('auth', result)

	# Apply the action to the ticket
	result.update(ticket_actions(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		),
		ticket_id,
		action,
		request.query.email, user_auth.get_email_from_id(request.query.o)
	))

	# Update table for this user
	result.update(user_tickets_details(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		), request.query.email))

	result.update({'username': user_auth.get_email_from_id(request.query.o)})
	result.update({'email': request.query.email})
	result.update({'username_id': request.query.o})

	# Is there any URGENT ticket?
	result.update({'urgent': get_urgent_tickets(rt_object)})

	result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})


	modify_ticket(
			rt_object,
			ticket_id,
			{
				'status': 'archived',
				
			}
		)

	return template('history', result)
Beispiel #10
0
def test_ticket_actions_unknown_option():
    rt_object = RTApiMock()
    rt_object.set_return(
        [
                u'id: ticket/887677',
                u'owner: [email protected]',
                u'subject: create rt dashboard',
                u'status: open',
                u'priority: 26',
                u'cf.{servico}: csc-gsiic',
                u'cf.{is - informatica e sistemas}: dir-inbox',
        ]
    )
    result = ticket_actions(rt_object, '887677', 'not_known', '*****@*****.**', '*****@*****.**')
    assert rt_object.data == {
        'query': 'id = "887677"',
        'format': 'l'
    }
    assert rt_object.uri == '/search/ticket'
    assert result == {
        'action_result': 'Still working on it... sorry for the inconvenience!'
    }
Beispiel #11
0
def ticket_action_2(ticket_id, action):
    start_time = time()

    result = create_default_result()
    if request.query.o == "" or not user_auth.check_id(request.query.o):
        result.update({"message": ""})
        return template("auth", result)

    # Apply the action to the ticket
    result.update(
        ticket_actions(
            user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)),
            ticket_id,
            action,
            request.query.email,
            user_auth.get_email_from_id(request.query.o),
        )
    )

    # Update table for this user
    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)), request.query.email
        )
    )

    result.update({"username": user_auth.get_email_from_id(request.query.o)})
    result.update({"email": request.query.email})
    result.update({"username_id": request.query.o})

    # Is there any URGENT ticket?
    result.update({"urgent": get_urgent_tickets(rt_object)})

    result.update({"time_spent": "%0.2f seconds" % (time() - start_time)})
    if request.query.email == "dir" or request.query.email == "dir-inbox" or request.query.email == "unknown":
        return template("ticket_list", result)
    else:
        return template("detail", result)