diff --git a/sentry_youtrack/configuration.py b/sentry_youtrack/configuration.py index 2d7340f..d85990b 100644 --- a/sentry_youtrack/configuration.py +++ b/sentry_youtrack/configuration.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- from requests.exceptions import ConnectionError, HTTPError, SSLError from sentry.exceptions import PluginError from django.utils.translation import ugettext_lazy as _ @@ -140,7 +141,7 @@ def get_project_fields_list(self, client, project_id): else: self.client_errors['project'] = self.error_message['project_unknown'] - def get_projects(self, client): + def get_projects(self, client, project_id): try: return list(client.get_projects()) except (HTTPError, ConnectionError) as e: diff --git a/sentry_youtrack/youtrack.py b/sentry_youtrack/youtrack.py index 0a8aacf..2dbc7a0 100644 --- a/sentry_youtrack/youtrack.py +++ b/sentry_youtrack/youtrack.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- import requests import logging from bs4 import BeautifulSoup @@ -156,14 +157,22 @@ def get_user(self, username): def get_projects(self): url = self.url + self.PROJECTS_URL response = self.request(url, method='get') - for project in BeautifulSoup(response.text, 'xml').projects: + data = BeautifulSoup(response.text, 'xml') + for project in data.projectShorts: yield {'id': project['shortName'], 'name': project['name']} def get_priorities(self): - return self._get_custom_field_values('bundle', 'Priorities') + try: + return self._get_custom_field_values('bundle', 'Priorities') + except: + return self._get_custom_field_values('bundle', u'Приоритеты') def get_issue_types(self): - return self._get_custom_field_values('bundle', 'Types') + try: + return self._get_custom_field_values('bundle', 'Types') + except: + return self._get_custom_field_values('bundle', u'Типы') + def get_project_issues(self, project_id, query=None, offset=0, limit=15): url = self.url + self.ISSUES_URL.replace('', project_id) diff --git a/setup.py b/setup.py index 0f25b76..907432c 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def run_tests(self): license='BSD', packages=find_packages(), install_requires=[ - 'beautifulsoup4>=4.5.1', + 'beautifulsoup4', ], include_package_data=True, zip_safe=False, @@ -65,7 +65,7 @@ def run_tests(self): }, tests_require=[ 'pytest', - 'vcrpy>=1.7.3', - 'sentry>=8.0.0', + 'vcrpy', + 'sentry>=9.1.0', ] ) diff --git a/tests/cassettes/test_get_project_name.yaml b/tests/cassettes/test_get_project_name.yaml index 19d71b3..fadea4c 100644 --- a/tests/cassettes/test_get_project_name.yaml +++ b/tests/cassettes/test_get_project_name.yaml @@ -8,9 +8,7 @@ interactions: uri: https://youtrack.myjetbrains.com/rest/admin/project/myproject response: body: {string: !!python/unicode ''} + name="My project" id="myproject" archived="false" lead="root"/>'} headers: access-control-expose-headers: [Location] cache-control: ['no-cache, no-store, no-transform, must-revalidate'] diff --git a/tests/cassettes/test_get_projects.yaml b/tests/cassettes/test_get_projects.yaml index 92a01ee..c769397 100644 --- a/tests/cassettes/test_get_projects.yaml +++ b/tests/cassettes/test_get_projects.yaml @@ -7,8 +7,8 @@ interactions: method: GET uri: https://youtrack.myjetbrains.com/rest/project/all response: - body: {string: !!python/unicode ''} + body: {string: !!python/unicode ''} headers: access-control-expose-headers: [Location] cache-control: ['no-cache, no-store, no-transform, must-revalidate'] diff --git a/tests/cassettes/yt_config.yaml b/tests/cassettes/yt_config.yaml index 7333259..da7e588 100644 --- a/tests/cassettes/yt_config.yaml +++ b/tests/cassettes/yt_config.yaml @@ -44,8 +44,8 @@ interactions: method: GET uri: https://youtrack.myjetbrains.com/rest/project/all response: - body: {string: !!python/unicode ''} + body: {string: !!python/unicode ''} headers: access-control-expose-headers: [Location] cache-control: ['no-cache, no-store, no-transform, must-revalidate']