Skip to content
This repository was archived by the owner on Aug 28, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sentry_youtrack/configuration.py
Original file line number Diff line number Diff line change
@@ -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 _
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions sentry_youtrack/youtrack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
import requests
import logging
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -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>', project_id)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -65,7 +65,7 @@ def run_tests(self):
},
tests_require=[
'pytest',
'vcrpy>=1.7.3',
'sentry>=8.0.0',
'vcrpy',
'sentry>=9.1.0',
]
)
4 changes: 1 addition & 3 deletions tests/cassettes/test_get_project_name.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ interactions:
uri: https://youtrack.myjetbrains.com/rest/admin/project/myproject
response:
body: {string: !!python/unicode '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><project
name="My project" id="myproject" archived="false" lead="root" assigneesUrl="https://youtrack.myjetbrains.com/rest/admin/project/myproject/assignee"
subsystemsUrl="https://youtrack.myjetbrains.com/rest/admin/project/myproject/subsystem"
buildsUrl="https://youtrack.myjetbrains.com/rest/admin/project/myproject/build" versionsUrl="https://youtrack.myjetbrains.com/rest/admin/project/myproject/version"/>'}
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']
Expand Down
4 changes: 2 additions & 2 deletions tests/cassettes/test_get_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interactions:
method: GET
uri: https://youtrack.myjetbrains.com/rest/project/all
response:
body: {string: !!python/unicode '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><projects><project
name="My project" shortName="myproject"/><project name="Test project" shortName="testproject"/></projects>'}
body: {string: !!python/unicode '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><projectShorts><project
name="My project" shortName="myproject"/><project name="Test project" shortName="testproject"/></projectShorts>'}
headers:
access-control-expose-headers: [Location]
cache-control: ['no-cache, no-store, no-transform, must-revalidate']
Expand Down
4 changes: 2 additions & 2 deletions tests/cassettes/yt_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ interactions:
method: GET
uri: https://youtrack.myjetbrains.com/rest/project/all
response:
body: {string: !!python/unicode '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><projects><project
name="My project" shortName="myproject"/><project name="Test project" shortName="testproject"/></projects>'}
body: {string: !!python/unicode '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><projectShorts><project
name="My project" shortName="myproject"/><project name="Test project" shortName="testproject"/></projectShorts>'}
headers:
access-control-expose-headers: [Location]
cache-control: ['no-cache, no-store, no-transform, must-revalidate']
Expand Down