-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_requesttracker.py
58 lines (45 loc) · 2.18 KB
/
test_requesttracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import unittest
import rt
import requesttracker
from errbot.backends.test import testbot
from errbot import plugin_manager
RT_CONFIG = {'USER': os.environ.get('RT_USER'),
'PASSWORD': os.environ.get('RT_PASSWORD'),
'DISPLAY_URL': os.environ.get('RT_DISPLAY_URL'),
'REST_URL': os.environ.get('RT_REST_URL')}
class TestRT(object):
extra_plugin_dir = '.'
def test_configuration(self, testbot):
testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
assert 'Plugin configuration done.' in testbot.pop_message()
def test_find_ticket(self, testbot):
test_subject = 'err-request-tracker'
test_requestor = 'foo@example.com'
test_text = 'Testing https://github.com/alimac/err-request-tracker'
testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
assert 'Plugin configuration done.' in testbot.pop_message()
tracker = rt.Rt(RT_CONFIG['REST_URL'])
tracker.login(RT_CONFIG['USER'], RT_CONFIG['PASSWORD'])
try:
ticket_id = tracker.create_ticket(Queue='General',
Subject=test_subject,
Requestors=test_requestor,
Text=test_text)
ticket = tracker.get_ticket(ticket_id)
except Exception as e:
raise Exception("Unable to create a test ticket: " + str(e))
testbot.push_message(str(ticket_id))
assert "%s (%s%s) in General from %s" % (
test_subject,
RT_CONFIG['DISPLAY_URL'],
str(ticket_id),
test_requestor) in testbot.pop_message()
def test_find_nonexistent_ticket(self, testbot):
testbot.push_message('!plugin config RT ' + str(RT_CONFIG))
assert 'Plugin configuration done.' in testbot.pop_message()
tracker = rt.Rt(RT_CONFIG['REST_URL'])
tracker.login(RT_CONFIG['USER'], RT_CONFIG['PASSWORD'])
testbot.push_message('999999999999999999999999999999999999999999999')
expected = "Sorry, that ticket does not exist or I cannot access it."
assert expected in testbot.pop_message()