This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14735d1
commit effd98c
Showing
6 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
sudo: false | ||
language: python | ||
services: | ||
- memcached | ||
- postgresql | ||
- redis-server | ||
python: | ||
- '2.7' | ||
cache: pip | ||
deploy: | ||
provider: pypi | ||
user: getsentry | ||
password: | ||
secure: Cckg3cvzfGBAKuSZ++eDLrezxxZCMBs97ZnDHhfLxpwbMhZXquXmkQHoOmd/7qUq5Yijdzz7XQb17qh3rlE+WcB+htmd+m3QEu2YIk8BwFFVE5CeRus7ALlNsYyn0dWv8wpbqGVihpF1pbKlIY+NUDD4MTICTTQrMU4CfpPEE6E= | ||
on: | ||
tags: true | ||
distributions: sdist bdist_wheel | ||
install: | ||
- make install-tests | ||
script: | ||
- flake8 | ||
- py.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
develop: | ||
pip install -e . | ||
|
||
install-tests: develop | ||
pip install .[tests] | ||
|
||
.PHONY: develop install-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from __future__ import absolute_import | ||
|
||
pytest_plugins = ['sentry.utils.pytest'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[bdist_wheel] | ||
universal = 1 | ||
|
||
[pytest] | ||
python_files = test*.py | ||
addopts = --tb=native -p no:doctest | ||
norecursedirs = bin dist docs htmlcov script hooks node_modules .* {args} | ||
|
||
[flake8] | ||
ignore = F999,E501,E128,E124,E402,W503,E731,C901 | ||
max-line-length = 100 | ||
exclude = .tox,.git,*/migrations/*,node_modules/*,docs/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import absolute_import | ||
|
||
import responses | ||
from exam import fixture | ||
from django.contrib.auth.models import AnonymousUser | ||
from django.forms import ValidationError | ||
from django.test import RequestFactory | ||
from django.test.utils import override_settings | ||
from sentry.testutils import TestCase | ||
from sentry.utils import json | ||
from social_auth.models import UserSocialAuth | ||
|
||
from sentry_github.plugin import GitHubPlugin | ||
|
||
|
||
class GitHubPluginTest(TestCase): | ||
@fixture | ||
def plugin(self): | ||
return GitHubPlugin() | ||
|
||
@fixture | ||
def request(self): | ||
return RequestFactory() | ||
|
||
def test_get_issue_label(self): | ||
group = self.create_group(message='Hello world', culprit='foo.bar') | ||
assert self.plugin.get_issue_label(group, 1) == 'GH-1' | ||
|
||
def test_get_issue_url(self): | ||
self.plugin.set_option('repo', 'getsentry/sentry', self.project) | ||
group = self.create_group(message='Hello world', culprit='foo.bar') | ||
assert self.plugin.get_issue_url(group, 1) == 'https://github.com/getsentry/sentry/issues/1' | ||
self.plugin.set_option('github_url', 'http://example.com', self.project) | ||
assert self.plugin.get_issue_url(group, 1) == 'http://example.com/getsentry/sentry/issues/1' | ||
|
||
def test_is_configured(self): | ||
assert self.plugin.is_configured(None, self.project) is False | ||
self.plugin.set_option('repo', 'getsentry/sentry', self.project) | ||
assert self.plugin.is_configured(None, self.project) is True | ||
|
||
@responses.activate | ||
@override_settings(GITHUB_APP_ID='abc', GITHUB_API_SECRET='123') | ||
def test_create_issue(self): | ||
self.plugin.set_option('repo', 'getsentry/sentry', self.project) | ||
group = self.create_group(message='Hello world', culprit='foo.bar') | ||
|
||
request = self.request.get('/') | ||
request.user = AnonymousUser() | ||
form_data = { | ||
'title': 'Hello', | ||
'description': 'Fix this.', | ||
} | ||
with self.assertRaises(ValidationError): | ||
self.plugin.create_issue(request, group, form_data) | ||
|
||
request.user = self.user | ||
self.login_as(self.user) | ||
UserSocialAuth.objects.create(user=self.user, provider=self.plugin.auth_provider, extra_data={'access_token': 'foo'}) | ||
|
||
responses.add(responses.POST, 'https://api.github.com/repos/getsentry/sentry/issues', | ||
body='{"number": 1}') | ||
assert self.plugin.create_issue(request, group, form_data) == 1 | ||
request = responses.calls[0].request | ||
payload = json.loads(request.body) | ||
assert payload == { | ||
'title': 'Hello', | ||
'body': 'Fix this.', | ||
} |