Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Add basic CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Feb 8, 2016
1 parent a4a76e5 commit 6a90460
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sudo: false
language: python
services:
- memcached
- postgresql
- redis-server
python:
- "2.7"
cache:
directories:
- node_modules
- $HOME/.cache/pip
deploy:
provider: pypi
user: getsentry
password:
secure: NMwOI1H9arp2vbgaidx9OY6y8990hiu0WsHtowEvEdGKXNzAQcy0sW3SoKcB6FN0bk11xhj49+5C++KAwMYwE/SL8Y5OoZ1/iYVI4/XlWNukr+1/pfPKVMgw3v5W+pL5Ba9TBdFfIoFPNYUDPLItSSjg94Bm95034gBkYWC5Hl0=
on:
tags: true
distributions: 'sdist bdist_wheel'
env:
global:
- PIP_DOWNLOAD_CACHE=".pip_download_cache"
install:
- make develop
script:
- PYFLAKES_NODOCTEST=1 flake8 src
- py.test
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Copyright (c) 2016, Functional Software, Inc
Copyright (c) 2013, Adam Thurlow
All rights reserved.

Expand Down
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.PHONY: clean develop install-tests lint publish test

develop:
pip install "pip>=7"
pip install -e .
make install-tests

install-tests:
pip install .[tests]

lint:
@echo "--> Linting python"
flake8
@echo ""

test:
@echo "--> Running Python tests"
py.test tests || exit 1
@echo ""

publish:
python setup.py sdist bdist_wheel upload

clean:
rm -rf *.egg-info src/*.egg-info
rm -rf dist build
5 changes: 5 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import

pytest_plugins = [
'sentry.utils.pytest'
]
12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[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/*
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from setuptools import setup, find_packages

install_requires = [
'sentry>=6.0.0',
'sentry>=7.0.0',
'BeautifulSoup>=3.2.1'
]

f = open('README.rst')
readme = f.read()
f.close()
tests_require = [
'exam',
'flake8>=2.0,<2.1',
'responses',
]

setup(
name='sentry-jira',
Expand All @@ -17,10 +19,13 @@
author_email='thurloat@gmail.com',
url='http://github.com/thurloat/sentry-jira',
description='A Sentry extension which creates JIRA issues from sentry events.',
long_description=readme,
long_description=open('README.rst').read(),
license='BSD',
packages=find_packages(),
install_requires=install_requires,
extras_require={
'tests': tests_require,
},
entry_points={
'sentry.apps': [
'sentry_jira = sentry_jira',
Expand Down
40 changes: 40 additions & 0 deletions tests/sentry_jira/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import absolute_import

import responses

from django.http import HttpRequest
from exam import fixture
from sentry.models import GroupMeta
from sentry.testutils import TestCase

from sentry_jira.plugin import JIRAPlugin


class JIRAPluginTest(TestCase):
@fixture
def plugin(self):
return JIRAPlugin()

# TODO(dcramer): assert request body
# TODO(dcramer): pull full fixture from JIRA
@responses.activate
def test_create_issue(self):
responses.add('POST', 'https://jira.atlassian.com/rest/api/2/issue',
json={"key": "JIRA-1234"})

self.plugin.set_option('instance_url', 'https://jira.atlassian.com', self.project)
self.plugin.set_option('username', 'example', self.project)
self.plugin.set_option('password', 'example', self.project)

request = HttpRequest()
group = self.create_group(message='Hello world', culprit='foo.bar')
event = self.create_event(group=group, message='Hello world')

form_data = {

}

with self.options({'system.url-prefix': 'http://example.com'}):
response = self.plugin.create_issue(request, group, form_data)

assert response == ('JIRA-1234', None)

0 comments on commit 6a90460

Please sign in to comment.