Skip to content
Snippets Groups Projects
Commit e3749092 authored by Jiří Machálek's avatar Jiří Machálek
Browse files

Merge remote-tracking branch 'github/pr/6'

- merge Stewart Perrygrove contribution with short format history
parents 61f5789c d885968d
No related branches found
No related tags found
No related merge requests found
......@@ -647,6 +647,24 @@ class Rt:
return items
except:
return []
def get_short_history(self, ticket_id):
""" Get set of short history items
:param ticket_id: ID of ticket
:returns: List of history items ordered increasingly by time of event.
Each history item is a tuple containing (id, Description)
"""
msg = self.__request('ticket/%s/history' % (str(ticket_id),))
items = []
if len(msg) != 0 and self.__get_status_code(msg) == 200:
short_hist_lines = msg.split('\n')
if len(short_hist_lines) >= 4:
for line in short_hist_lines[4:]:
if ': ' in line:
hist_id, desc = line.split(': ')
items.append((int(hist_id), desc))
return items
def reply(self, ticket_id, text='', cc='', bcc='', files=[]):
""" Sends email message to the contacts in ``Requestors`` field of
......
......@@ -121,6 +121,10 @@ class RtTestCase(unittest.TestCase):
hist = tracker.get_history(ticket_id)
self.assertTrue(len(hist) > 0, 'Empty ticket history.')
self.assertEqual(hist[0]['Content'], ticket_text, 'Ticket text was not receives is it was submited.')
# get_short_history
short_hist = tracker.get_short_history(ticket_id)
self.assertTrue(len(short_hist) > 0, 'Empty ticket short history.')
self.assertEqual(short_hist[0][1], 'Ticket created by john.foo')
# create 2nd ticket
ticket2_subject = 'Testing issue ' + "".join([random.choice(string.ascii_letters) for i in range(15)])
ticket2_id = tracker.create_ticket(Subject=ticket2_subject)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment