Hello community, here is the log from the commit of package python-rt for openSUSE:Factory checked in at 2018-08-06 11:54:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-rt (Old) and /work/SRC/openSUSE:Factory/.python-rt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-rt" Mon Aug 6 11:54:35 2018 rev:2 rq:627540 version:1.0.11 Changes: -------- --- /work/SRC/openSUSE:Factory/python-rt/python-rt.changes 2018-03-20 21:56:08.822783485 +0100 +++ /work/SRC/openSUSE:Factory/.python-rt.new/python-rt.changes 2018-08-06 11:54:37.885281213 +0200 @@ -1,0 +2,8 @@ +Sun Jul 29 17:34:16 UTC 2018 - [email protected] + +- update to version 1.0.11: + - Added parameter to set the content type in reply() and comment() (#12). + - Added parameter Format to search() (#17). + - Tests: Update to new demo instance, fixing tests. + +------------------------------------------------------------------- Old: ---- rt-1.0.10.tar.gz New: ---- rt-1.0.11.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-rt.spec ++++++ --- /var/tmp/diff_new_pack.BIOWoX/_old 2018-08-06 11:54:38.445282186 +0200 +++ /var/tmp/diff_new_pack.BIOWoX/_new 2018-08-06 11:54:38.449282193 +0200 @@ -13,21 +13,23 @@ # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + # Tests require internet connection %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-rt -Version: 1.0.10 +Version: 1.0.11 Release: 0 -License: GPL-3.0 Summary: Python interface to Request Tracker API -Url: https://github.com/CZ-NIC/python-rt +License: GPL-3.0-only Group: Development/Languages/Python +Url: https://github.com/CZ-NIC/python-rt Source: https://files.pythonhosted.org/packages/source/r/rt/rt-%{version}.tar.gz -BuildRequires: python-rpm-macros BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} BuildRequires: fdupes +BuildRequires: python-rpm-macros Requires: python-nose Requires: python-requests Requires: python-six ++++++ rt-1.0.10.tar.gz -> rt-1.0.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/CHANGES new/rt-1.0.11/CHANGES --- old/rt-1.0.10/CHANGES 2017-12-01 13:25:41.000000000 +0100 +++ new/rt-1.0.11/CHANGES 2018-07-16 14:39:22.000000000 +0200 @@ -1,3 +1,8 @@ +v1.0.11, unreleased +- Added parameter to set the content type in reply() and comment() (#12). +- Added parameter Format to search() (#17). +- Tests: Update to new demo instance, fixing tests. + v1.0.10, 2017-02-22 - PEP8 fixes - update .travis.yml to update python interpreter list and some other small changes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/PKG-INFO new/rt-1.0.11/PKG-INFO --- old/rt-1.0.10/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/rt-1.0.11/PKG-INFO 2018-07-16 14:51:02.000000000 +0200 @@ -0,0 +1,83 @@ +Metadata-Version: 1.1 +Name: rt +Version: 1.0.11 +Summary: Python interface to Request Tracker API +Home-page: https://github.com/CZ-NIC/python-rt +Author: Jiri Machalek +Author-email: [email protected] +License: GNU General Public License (GPL) +Description: + .. image:: https://travis-ci.org/CZ-NIC/python-rt.svg?branch=master + :target: https://travis-ci.org/CZ-NIC/python-rt + + ============================================== + Rt - Python interface to Request Tracker API + ============================================== + + Python implementation of REST API described here: https://rt-wiki.bestpractical.com/wiki/REST + + REQUIREMENTS + ============ + + This module uses following Python modules: + + - requests (http://docs.python-requests.org/) + - nose (http://nose.readthedocs.org) + - six (http://pythonhosted.org/six/) + + Requirements can be installed running:: + + pip install -r requirements.txt + + LICENCE + ======= + + This module is distributed under the terms of GNU General Public Licence v3 + and was developed by CZ.NIC Labs - research and development department of + CZ.NIC association - top level domain registy for .CZ. Copy of the GNU + General Public License is distributed along with this module. + + USAGE + ===== + + An example is worth a thousand words:: + + >>> import rt + >>> tracker = rt.Rt('http://localhost/rt/REST/1.0/', 'user_login', 'user_pass') + >>> tracker.login() + True + >>> map(lambda x: x['id'], tracker.search(Queue='helpdesk', Status='open')) + ['ticket/1', 'ticket/2', 'ticket/10', 'ticket/15'] + >>> tracker.create_ticket(Queue='helpdesk', \ + ... Subject='Coffee (important)', Text='Help I Ran Out of Coffee!') + 19 + >>> tracker.edit_ticket(19, Requestors='[email protected]') + True + >>> tracker.reply(19, text='Do you know Starbucks?') + True + >>> tracker.logout() + True + + Please use docstrings to see how to use different functions. They are written + in ReStructuredText. You can also generate HTML documentation by running + ``make html`` in doc directory (Sphinx required). + + OFFICIAL SITE + ============= + + Project site and issue tracking: + https://github.com/CZ-NIC/python-rt + + Git repository: + git://github.com/CZ-NIC/python-rt.git + + +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Environment :: Console +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) +Classifier: Operating System :: POSIX +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 3.2 +Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/rt.egg-info/PKG-INFO new/rt-1.0.11/rt.egg-info/PKG-INFO --- old/rt-1.0.10/rt.egg-info/PKG-INFO 2017-12-01 16:45:07.000000000 +0100 +++ new/rt-1.0.11/rt.egg-info/PKG-INFO 2018-07-16 14:51:02.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: rt -Version: 1.0.10 +Version: 1.0.11 Summary: Python interface to Request Tracker API Home-page: https://github.com/CZ-NIC/python-rt Author: Jiri Machalek diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/rt.egg-info/requires.txt new/rt-1.0.11/rt.egg-info/requires.txt --- old/rt-1.0.10/rt.egg-info/requires.txt 2017-12-01 16:45:07.000000000 +0100 +++ new/rt-1.0.11/rt.egg-info/requires.txt 2018-07-16 14:51:02.000000000 +0200 @@ -1,3 +1,2 @@ -nose requests six diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/rt.py new/rt-1.0.11/rt.py --- old/rt-1.0.10/rt.py 2017-12-01 13:25:41.000000000 +0100 +++ new/rt-1.0.11/rt.py 2018-07-16 14:47:27.000000000 +0200 @@ -25,12 +25,12 @@ * untake tickets """ -import re import os -import requests +import re import warnings -from requests.auth import HTTPBasicAuth, HTTPDigestAuth +import requests +from requests.auth import HTTPBasicAuth, HTTPDigestAuth from six import iteritems from six.moves import range @@ -392,7 +392,7 @@ """ return self.search(Queue=queue, order='-LastUpdated', LastUpdatedBy__notexact=self.default_login, LastUpdated__gt=since) - def search(self, Queue=None, order=None, raw_query=None, **kwargs): + def search(self, Queue=None, order=None, raw_query=None, Format='l', **kwargs): """ Search arbitrary needles in given fields and queue. Example:: @@ -413,6 +413,10 @@ kwargs, so use these instead of including them in the raw query. You can refer to the RT query builder. If passing raw_query, all other **kwargs will be ignored. + :keyword Format: Format of the query: + - i: only `id' fields are populated + - s: only `id' and `subject' fields are populated + - l: multi-line format, all fields are populated :keyword kwargs: Other arguments possible to set if not passing raw_query: Requestors, Subject, Cc, AdminCc, Owner, Status, @@ -471,7 +475,7 @@ get_params['query'] = ' AND '.join('(' + part + ')' for part in query) if order: get_params['orderby'] = order - get_params['format'] = 'l' + get_params['format'] = Format msg = self.__request(url, get_params=get_params) lines = msg.split('\n') @@ -481,37 +485,51 @@ if lines[2].startswith('No matching results.'): return [] - msgs = map(lambda x: x.split('\n'), msg.split('\n--\n')) - items = [] - for msg in msgs: - pairs = {} - req_matching = [i for i, m in enumerate(msg) if self.RE_PATTERNS['requestors_pattern'].match(m)] - req_id = req_matching[0] if req_matching else None - if not req_id: - raise UnexpectedMessageFormat('Missing line starting with `Requestors:`.') - for i in range(req_id): - if ': ' in msg[i]: - header, content = msg[i].split(': ', 1) - pairs[header.strip()] = content.strip() - requestors = [msg[req_id][12:]] - req_id += 1 - while (req_id < len(msg)) and (msg[req_id][:12] == ' ' * 12): - requestors.append(msg[req_id][12:]) + if Format == 'l': + msgs = map(lambda x: x.split('\n'), msg.split('\n--\n')) + items = [] + for msg in msgs: + pairs = {} + req_matching = [i for i, m in enumerate(msg) if self.RE_PATTERNS['requestors_pattern'].match(m)] + req_id = req_matching[0] if req_matching else None + if not req_id: + raise UnexpectedMessageFormat('Missing line starting with `Requestors:`.') + for i in range(req_id): + if ': ' in msg[i]: + header, content = msg[i].split(': ', 1) + pairs[header.strip()] = content.strip() + requestors = [msg[req_id][12:]] req_id += 1 - pairs['Requestors'] = self.__normalize_list(requestors) - for i in range(req_id, len(msg)): - if ': ' in msg[i]: - header, content = msg[i].split(': ', 1) - pairs[header.strip()] = content.strip() - if pairs: - items.append(pairs) - - if 'Cc' in pairs: - pairs['Cc'] = self.__normalize_list(pairs['Cc']) - if 'AdminCc' in pairs: - pairs['AdminCc'] = self.__normalize_list(pairs['AdminCc']) - - return items + while (req_id < len(msg)) and (msg[req_id][:12] == ' ' * 12): + requestors.append(msg[req_id][12:]) + req_id += 1 + pairs['Requestors'] = self.__normalize_list(requestors) + for i in range(req_id, len(msg)): + if ': ' in msg[i]: + header, content = msg[i].split(': ', 1) + pairs[header.strip()] = content.strip() + if pairs: + items.append(pairs) + + if 'Cc' in pairs: + pairs['Cc'] = self.__normalize_list(pairs['Cc']) + if 'AdminCc' in pairs: + pairs['AdminCc'] = self.__normalize_list(pairs['AdminCc']) + return items + elif Format == 's': + items = [] + msgs = msg.splitlines()[2:] + for msg in msgs: + ticket_id, subject = msg.split(': ', 1) + items.append({'id': 'ticket/' + ticket_id, 'Subject': subject}) + return items + elif Format == 'i': + items = [] + msgs = msg.splitlines()[2:] + for msg in msgs: + _, ticket_id = msg.split('/', 1) + items.append({'id': 'ticket/' + ticket_id}) + return items def get_ticket(self, ticket_id): """ Fetch ticket by its ID. @@ -544,7 +562,7 @@ * TimeLeft :raises UnexpectedMessageFormat: Unexpected format of returned message. """ - msg = self.__request('ticket/{}/show'.format(str(ticket_id),)) + msg = self.__request('ticket/{}/show'.format(str(ticket_id), )) status_code = self.__get_status_code(msg) if status_code == 200: pairs = {} @@ -579,7 +597,7 @@ else: raise UnexpectedMessageFormat('Received status code is {:d} instead of 200.'.format(status_code)) - def create_ticket(self, Queue=None, **kwargs): + def create_ticket(self, Queue=None, files=[], **kwargs): """ Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: @@ -607,6 +625,8 @@ + list of some key, value pairs, probably default values. :keyword Queue: Queue where to create ticket + :keyword files: Files to attach as multipart/form-data + List of 2/3 tuples: (filename, file-like object, [content type]) :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, @@ -619,7 +639,7 @@ :returns: ID of new ticket or ``-1``, if creating failed """ - post_data = 'id: ticket/new\nQueue: {}\n'.format(Queue or self.default_queue,) + post_data = 'id: ticket/new\nQueue: {}\n'.format(Queue or self.default_queue, ) for key in kwargs: if key[:4] == 'Text': post_data += "{}: {}\n".format(key, re.sub(r'\n', r'\n ', kwargs[key])) @@ -627,7 +647,9 @@ post_data += "CF.{{{}}}: {}\n".format(key[3:], kwargs[key]) else: post_data += "{}: {}\n".format(key, kwargs[key]) - msg = self.__request('ticket/new', post_data={'content': post_data}) + for file_info in files: + post_data += "\nAttachment: {}".format(file_info[0], ) + msg = self.__request('ticket/new', post_data={'content': post_data}, files=files) for line in msg.split('\n')[2:-1]: res = self.RE_PATTERNS['ticket_created_pattern'].match(line) if res is not None: @@ -689,11 +711,13 @@ if transaction_id is None: # We are using "long" format to get all history items at once. # Each history item is then separated by double dash. - msgs = self.__request('ticket/{}/history?format=l'.format(str(ticket_id),)) + msgs = self.__request('ticket/{}/history?format=l'.format(str(ticket_id), )) else: msgs = self.__request('ticket/{}/history/id/{}'.format(str(ticket_id), str(transaction_id))) lines = msgs.split('\n') - if (len(lines) > 2) and (self.RE_PATTERNS['does_not_exist_pattern'].match(lines[2]) or self.RE_PATTERNS['not_related_pattern'].match(lines[2])): + if (len(lines) > 2) and ( + self.RE_PATTERNS['does_not_exist_pattern'].match(lines[2]) or self.RE_PATTERNS['not_related_pattern'].match( + lines[2])): return None msgs = msgs.split('\n--\n') items = [] @@ -742,7 +766,7 @@ Each history item is a tuple containing (id, Description). Returns None if ticket does not exist. """ - msg = self.__request('ticket/{}/history'.format(str(ticket_id),)) + msg = self.__request('ticket/{}/history'.format(str(ticket_id), )) items = [] lines = msg.split('\n') multiline_buffer = "" @@ -794,8 +818,8 @@ Bcc: {} Content-Type: {}""".format(str(ticket_id), action, re.sub(r'\n', r'\n ', text), cc, bcc, content_type)} for file_info in files: - post_data['content'] += "\nAttachment: {}".format(file_info[0],) - msg = self.__request('ticket/{}/comment'.format(str(ticket_id),), + post_data['content'] += "\nAttachment: {}".format(file_info[0], ) + msg = self.__request('ticket/{}/comment'.format(str(ticket_id), ), post_data=post_data, files=files) return self.__get_status_code(msg) == 200 @@ -872,7 +896,7 @@ Tuple format: (id, name, content_type, size) Returns None if ticket does not exist. """ - msg = self.__request('ticket/{}/attachments'.format(str(ticket_id),)) + msg = self.__request('ticket/{}/attachments'.format(str(ticket_id), )) lines = msg.split('\n') if (len(lines) > 2) and self.RE_PATTERNS['does_not_exist_pattern'].match(lines[2]): return None @@ -952,7 +976,8 @@ msg = self.__request('ticket/{}/attachments/{}'.format(str(ticket_id), str(attachment_id)), text_response=False) msg = msg.split(b'\n') - if (len(msg) > 2) and (self.RE_PATTERNS['invalid_attachment_pattern_bytes'].match(msg[2]) or self.RE_PATTERNS['does_not_exist_pattern_bytes'].match(msg[2])): + if (len(msg) > 2) and (self.RE_PATTERNS['invalid_attachment_pattern_bytes'].match(msg[2]) or self.RE_PATTERNS[ + 'does_not_exist_pattern_bytes'].match(msg[2])): return None msg = msg[2:] head_matching = [i for i, m in enumerate(msg) if self.RE_PATTERNS['headers_pattern_bytes'].match(m)] @@ -1006,7 +1031,8 @@ (str(ticket_id), str(attachment_id)), text_response=False) lines = msg.split(b'\n', 3) - if (len(lines) == 4) and (self.RE_PATTERNS['invalid_attachment_pattern_bytes'].match(lines[2]) or self.RE_PATTERNS['does_not_exist_pattern_bytes'].match(lines[2])): + if (len(lines) == 4) and (self.RE_PATTERNS['invalid_attachment_pattern_bytes'].match(lines[2]) or self.RE_PATTERNS[ + 'does_not_exist_pattern_bytes'].match(lines[2])): return None return msg[msg.find(b'\n') + 2:-3] @@ -1041,9 +1067,9 @@ None is returned if user does not exist. :raises UnexpectedMessageFormat: In case that returned status code is not 200 """ - msg = self.__request('user/{}'.format(str(user_id),)) + msg = self.__request('user/{}'.format(str(user_id), )) status_code = self.__get_status_code(msg) - if(status_code == 200): + if (status_code == 200): pairs = {} lines = msg.split('\n') if (len(lines) > 2) and self.RE_PATTERNS['does_not_exist_pattern'].match(lines[2]): @@ -1155,7 +1181,7 @@ """ msg = self.__request('queue/{}'.format(str(queue_id))) status_code = self.__get_status_code(msg) - if(status_code == 200): + if (status_code == 200): pairs = {} lines = msg.split('\n') if (len(lines) > 2) and self.RE_PATTERNS['does_not_exist_pattern'].match(lines[2]): @@ -1187,7 +1213,8 @@ :raises InvalidUse: When invalid fields are set """ - valid_fields = set(('name', 'description', 'correspondaddress', 'commentaddress', 'initialpriority', 'finalpriority', 'defaultduein')) + valid_fields = set( + ('name', 'description', 'correspondaddress', 'commentaddress', 'initialpriority', 'finalpriority', 'defaultduein')) used_fields = set(map(lambda x: x.lower(), kwargs.keys())) if not used_fields <= valid_fields: @@ -1234,10 +1261,10 @@ None is returned if ticket does not exist. :raises UnexpectedMessageFormat: In case that returned status code is not 200 """ - msg = self.__request('ticket/{}/links/show'.format(str(ticket_id),)) + msg = self.__request('ticket/{}/links/show'.format(str(ticket_id), )) status_code = self.__get_status_code(msg) - if(status_code == 200): + if (status_code == 200): pairs = {} msg = msg.split('\n') if (len(msg) > 2) and self.RE_PATTERNS['does_not_exist_pattern'].match(msg[2]): @@ -1284,7 +1311,7 @@ post_data = '' for key in kwargs: post_data += "{}: {}\n".format(key, str(kwargs[key])) - msg = self.__request('ticket/{}/links'.format(str(ticket_id),), + msg = self.__request('ticket/{}/links'.format(str(ticket_id), ), post_data={'content': post_data}) state = msg.split('\n')[2] return self.RE_PATTERNS['links_updated_pattern'].match(state) is not None @@ -1333,7 +1360,7 @@ exist or user does not have ModifyTicket permission. """ msg = self.__request('ticket/{}/merge/{}'.format(str(ticket_id), - str(into_id))) + str(into_id))) state = msg.split('\n')[2] return self.RE_PATTERNS['merge_successful_pattern'].match(state) is not None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/setup.cfg new/rt-1.0.11/setup.cfg --- old/rt-1.0.10/setup.cfg 2017-12-01 13:25:41.000000000 +0100 +++ new/rt-1.0.11/setup.cfg 2018-07-16 14:51:02.000000000 +0200 @@ -1,2 +1,7 @@ [bdist_wheel] -universal=1 +universal = 1 + +[egg_info] +tag_build = +tag_date = 0 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/setup.py new/rt-1.0.11/setup.py --- old/rt-1.0.10/setup.py 2017-12-01 16:48:56.000000000 +0100 +++ new/rt-1.0.11/setup.py 2018-07-16 14:48:00.000000000 +0200 @@ -1,5 +1,4 @@ import os -import sys try: from setuptools import setup @@ -10,24 +9,23 @@ README = open(os.path.join(here, 'README.rst')).read() setup(name='rt', - version='1.0.10', - description='Python interface to Request Tracker API', - long_description=README, - license='GNU General Public License (GPL)', - author='Jiri Machalek', - author_email='[email protected]', - url='https://github.com/CZ-NIC/python-rt', - install_requires=['requests', 'six', 'nose'], - py_modules=['rt'], - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Operating System :: POSIX', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3.2', - 'Topic :: Software Development :: Libraries :: Python Modules' - ] -) - + version='1.0.11', + description='Python interface to Request Tracker API', + long_description=README, + license='GNU General Public License (GPL)', + author='Jiri Machalek', + author_email='[email protected]', + url='https://github.com/CZ-NIC/python-rt', + install_requires=['requests', 'six'], + py_modules=['rt'], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + 'Operating System :: POSIX', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.2', + 'Topic :: Software Development :: Libraries :: Python Modules' + ] + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rt-1.0.10/test_rt.py new/rt-1.0.11/test_rt.py --- old/rt-1.0.10/test_rt.py 2017-12-01 13:25:41.000000000 +0100 +++ new/rt-1.0.11/test_rt.py 2018-07-16 14:48:00.000000000 +0200 @@ -17,56 +17,57 @@ """ __docformat__ = "reStructuredText en" __authors__ = [ - '"Jiri Machalek" <[email protected]>' + '"Jiri Machalek" <[email protected]>' ] -import unittest import random import string +import unittest from six import iteritems from six.moves import range import rt -class RtTestCase(unittest.TestCase): +class RtTestCase(unittest.TestCase): RT_VALID_CREDENTIALS = { - 'RT4.2 stable': { - 'url': 'http://rt.easter-eggs.org/demos/4.2/REST/1.0', - 'admin': { - 'default_login': 'admin', - 'default_password': 'admin', - }, - 'john.foo': { - 'default_login': 'john.foo', - 'default_password': 'john.foo', - } - }, - 'RT4.4 dev': { - 'url': 'http://rt.easter-eggs.org/demos/4.4/REST/1.0', + 'RT4.4 stable': { + 'url': 'http://demo.request-tracker.fr/REST/1.0', 'admin': { - 'default_login': 'admin', - 'default_password': 'admin', + 'default_login': 'administrateur', + 'default_password': 'administrateur', }, - 'john.foo': { - 'default_login': 'john.foo', - 'default_password': 'john.foo', + 'support': { + 'default_login': 'support', + 'default_password': 'support', } }, + # HTTP timeout + # 'RT4.6 dev': { + # 'url': 'http://rt.easter-eggs.org/demos/4.6/REST/1.0', + # 'admin': { + # 'default_login': 'administrateur', + # 'default_password': 'administrateur', + # }, + # 'john.foo': { + # 'default_login': 'support', + # 'default_password': 'support', + # } + # }, } RT_INVALID_CREDENTIALS = { - 'RT4.2 stable (bad credentials)': { - 'url': 'http://rt.easter-eggs.org/demos/4.2/REST/1.0', + 'RT4.4 stable (bad credentials)': { + 'url': 'http://demo.request-tracker.fr/REST/1.0', 'default_login': 'idontexist', 'default_password': 'idonthavepassword', }, } RT_MISSING_CREDENTIALS = { - 'RT4.2 stable (missing credentials)': { - 'url': 'http://rt.easter-eggs.org/demos/4.2/REST/1.0', + 'RT4.4 stable (missing credentials)': { + 'url': 'http://demo.request-tracker.fr/REST/1.0', }, } @@ -80,7 +81,7 @@ def test_login_and_logout(self): for name in self.RT_VALID_CREDENTIALS: - tracker = rt.Rt(self.RT_VALID_CREDENTIALS[name]['url'], **self.RT_VALID_CREDENTIALS[name]['john.foo']) + tracker = rt.Rt(self.RT_VALID_CREDENTIALS[name]['url'], **self.RT_VALID_CREDENTIALS[name]['support']) self.assertTrue(tracker.login(), 'Invalid login to RT demo site ' + name) self.assertTrue(tracker.logout(), 'Invalid logout from RT demo site ' + name) for name, params in iteritems(self.RT_INVALID_CREDENTIALS): @@ -105,12 +106,12 @@ def test_ticket_operations(self): ticket_subject = 'Testing issue ' + "".join([random.choice(string.ascii_letters) for i in range(15)]) ticket_text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' - for name in ('RT4.2 stable', 'RT4.4 dev'): + for name in ('RT4.4 stable',): self.check_or_create_queue(name) url = self.RT_VALID_CREDENTIALS[name]['url'] - default_login = self.RT_VALID_CREDENTIALS[name]['john.foo']['default_login'] - default_password = self.RT_VALID_CREDENTIALS[name]['john.foo']['default_password'] + default_login = self.RT_VALID_CREDENTIALS[name]['support']['default_login'] + default_password = self.RT_VALID_CREDENTIALS[name]['support']['default_password'] tracker = rt.Rt(url, default_login=default_login, default_password=default_password) self.assertTrue(tracker.login(), 'Invalid login to RT demo site ' + name) # empty search result @@ -152,7 +153,7 @@ # 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') + self.assertEqual(short_hist[0][1], 'Ticket created by support') # 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) @@ -165,13 +166,15 @@ self.assertTrue(links1['DependsOn'][0].endswith('ticket/' + str(ticket2_id)), 'Unexpected value of link DependsOn.') links2 = tracker.get_links(ticket2_id) self.assertTrue('DependedOnBy' in links2, 'Missing just created link DependedOnBy.') - self.assertTrue(links2['DependedOnBy'][0].endswith('ticket/' + str(ticket_id)), 'Unexpected value of link DependedOnBy.') + self.assertTrue(links2['DependedOnBy'][0].endswith('ticket/' + str(ticket_id)), + 'Unexpected value of link DependedOnBy.') # reply with attachment attachment_content = b'Content of attachment.' attachment_name = 'attachment-name.txt' reply_text = 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' # should provide a content type as RT 4.0 type guessing is broken (missing use statement for guess_media_type in REST.pm) - self.assertTrue(tracker.reply(ticket_id, text=reply_text, files=[(attachment_name, attachment_content, 'text/plain')]), 'Reply to ticket returned False indicating error.') + self.assertTrue(tracker.reply(ticket_id, text=reply_text, files=[(attachment_name, attachment_content, 'text/plain')]), + 'Reply to ticket returned False indicating error.') at_ids = tracker.get_attachments_ids(ticket_id) self.assertTrue(at_ids, 'Emply list with attachment ids, something went wrong.') at_content = tracker.get_attachment_content(ticket_id, at_ids[-1]) @@ -185,8 +188,9 @@ # delete ticket self.assertTrue(tracker.edit_ticket(ticket_id, Status='deleted'), 'Ticket delete failed.') # get user - self.assertEqual(tracker.get_user(default_login)['EmailAddress'], default_login + '@no.mail', 'Bad user email received.') + self.assertEqual(tracker.get_user(default_login)['EmailAddress'], default_login + '@no.mail', + 'Bad user email received.') + if __name__ == '__main__': unittest.main() -
