Merge "Enable Py35 tests to run"
This commit is contained in:
commit
fa74fda51c
|
@ -17,6 +17,9 @@ import pymysql
|
||||||
from monasca_notification.common.repositories.base import base_repo
|
from monasca_notification.common.repositories.base import base_repo
|
||||||
from monasca_notification.common.repositories import exceptions as exc
|
from monasca_notification.common.repositories import exceptions as exc
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +52,7 @@ class MysqlRepo(base_repo.BaseRepo):
|
||||||
self._mysql = pymysql.connect(host=self._mysql_host,
|
self._mysql = pymysql.connect(host=self._mysql_host,
|
||||||
port=self._mysql_port,
|
port=self._mysql_port,
|
||||||
user=self._mysql_user,
|
user=self._mysql_user,
|
||||||
passwd=unicode(self._mysql_passwd).encode('utf-8'),
|
passwd=six.text_type(self._mysql_passwd).encode('utf-8'),
|
||||||
db=self._mysql_dbname,
|
db=self._mysql_dbname,
|
||||||
ssl=self._mysql_ssl,
|
ssl=self._mysql_ssl,
|
||||||
use_unicode=True,
|
use_unicode=True,
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Notification(object):
|
||||||
retry_count - number of times we've tried to send
|
retry_count - number of times we've tried to send
|
||||||
alarm - info that caused the notification
|
alarm - info that caused the notification
|
||||||
notifications that come after this one to remain uncommitted.
|
notifications that come after this one to remain uncommitted.
|
||||||
Note that data may include unicode strings.
|
Note that data may include six.text_type strings.
|
||||||
"""
|
"""
|
||||||
self.id = id
|
self.id = id
|
||||||
self.address = address
|
self.address = address
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import urlparse
|
|
||||||
|
|
||||||
from monasca_notification.plugins import abstract_notifier
|
from monasca_notification.plugins import abstract_notifier
|
||||||
|
|
||||||
|
from six.moves import urllib
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
notification.address = https://hipchat.hpcloud.net/v2/room/<room_id>/notification?auth_token=432432
|
notification.address = https://hipchat.hpcloud.net/v2/room/<room_id>/notification?auth_token=432432
|
||||||
|
|
||||||
|
@ -88,11 +90,11 @@ class HipChatNotifier(abstract_notifier.AbstractNotifier):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
hipchat_message = self._build_hipchat_message(notification)
|
hipchat_message = self._build_hipchat_message(notification)
|
||||||
parsed_url = urlparse.urlsplit(notification.address)
|
parsed_url = urllib.parse.urlsplit(notification.address)
|
||||||
|
|
||||||
query_params = urlparse.parse_qs(parsed_url.query)
|
query_params = urllib.parse.parse_qs(parsed_url.query)
|
||||||
# URL without query params
|
# URL without query params
|
||||||
url = urlparse.urljoin(notification.address, urlparse.urlparse(notification.address).path)
|
url = urllib.parse.urljoin(notification.address, urllib.parse.urlparse(notification.address).path)
|
||||||
|
|
||||||
# Default option is to do cert verification
|
# Default option is to do cert verification
|
||||||
verify = not self._config.get('insecure', True)
|
verify = not self._config.get('insecure', True)
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
import jira
|
import jira
|
||||||
import json
|
import json
|
||||||
import urlparse
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from monasca_notification.plugins.abstract_notifier import AbstractNotifier
|
from monasca_notification.plugins.abstract_notifier import AbstractNotifier
|
||||||
|
|
||||||
|
from six.moves import urllib
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Note:
|
Note:
|
||||||
This plugin doesn't support multi tenancy. Multi tenancy requires support for
|
This plugin doesn't support multi tenancy. Multi tenancy requires support for
|
||||||
|
@ -149,10 +151,10 @@ class JiraNotifier(AbstractNotifier):
|
||||||
|
|
||||||
jira_fields = self._build_jira_message(notification)
|
jira_fields = self._build_jira_message(notification)
|
||||||
|
|
||||||
parsed_url = urlparse.urlsplit(notification.address)
|
parsed_url = urllib.parse.urlsplit(notification.address)
|
||||||
query_params = urlparse.parse_qs(parsed_url.query)
|
query_params = urllib.parse.parse_qs(parsed_url.query)
|
||||||
# URL without query params
|
# URL without query params
|
||||||
url = urlparse.urljoin(notification.address, urlparse.urlparse(notification.address).path)
|
url = urllib.parse.urljoin(notification.address, urllib.parse.urlparse(notification.address).path)
|
||||||
|
|
||||||
jira_fields["project"] = query_params["project"][0]
|
jira_fields["project"] = query_params["project"][0]
|
||||||
if query_params.get("component"):
|
if query_params.get("component"):
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import urlparse
|
|
||||||
|
|
||||||
from monasca_notification.plugins import abstract_notifier
|
from monasca_notification.plugins import abstract_notifier
|
||||||
|
|
||||||
|
from six.moves import urllib
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
notification.address = https://slack.com/api/chat.postMessage?token=token&channel=#channel"
|
notification.address = https://slack.com/api/chat.postMessage?token=token&channel=#channel"
|
||||||
|
|
||||||
|
@ -77,10 +79,10 @@ class SlackNotifier(abstract_notifier.AbstractNotifier):
|
||||||
# Slack room has "#" as first character
|
# Slack room has "#" as first character
|
||||||
address = address.replace("#", "%23")
|
address = address.replace("#", "%23")
|
||||||
|
|
||||||
parsed_url = urlparse.urlsplit(address)
|
parsed_url = urllib.parse.urlsplit(address)
|
||||||
query_params = urlparse.parse_qs(parsed_url.query)
|
query_params = urllib.parse.parse_qs(parsed_url.query)
|
||||||
# URL without query params
|
# URL without query params
|
||||||
url = urlparse.urljoin(address, urlparse.urlparse(address).path)
|
url = urllib.parse.urljoin(address, urllib.parse.urlparse(address).path)
|
||||||
|
|
||||||
# Default option is to do cert verification
|
# Default option is to do cert verification
|
||||||
verify = not self._config.get('insecure', True)
|
verify = not self._config.get('insecure', True)
|
||||||
|
|
|
@ -10,3 +10,5 @@ funcsigs>=0.4;python_version=='2.7' or python_version=='2.6' # Apache-2.0
|
||||||
os-testr>=0.8.0 # Apache-2.0
|
os-testr>=0.8.0 # Apache-2.0
|
||||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||||
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
|
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
|
||||||
|
PyMySQL>=0.7.6 # MIT License
|
||||||
|
psycopg2>=2.5 # LGPL/ZPL
|
||||||
|
|
|
@ -19,10 +19,12 @@ import socket
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from monasca_notification.notification import Notification
|
from monasca_notification.notification import Notification
|
||||||
from monasca_notification.plugins import email_notifier
|
from monasca_notification.plugins import email_notifier
|
||||||
|
|
||||||
UNICODE_CHAR = unichr(2344)
|
UNICODE_CHAR = six.unichr(2344)
|
||||||
UNICODE_CHAR_ENCODED = UNICODE_CHAR.encode("utf-8")
|
UNICODE_CHAR_ENCODED = UNICODE_CHAR.encode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,18 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import mock
|
import mock
|
||||||
import Queue
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from monasca_notification import notification as m_notification
|
from monasca_notification import notification as m_notification
|
||||||
from monasca_notification.plugins import hipchat_notifier
|
from monasca_notification.plugins import hipchat_notifier
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
import Queue as queue
|
||||||
|
else:
|
||||||
|
import queue
|
||||||
|
|
||||||
|
|
||||||
def alarm(metrics):
|
def alarm(metrics):
|
||||||
return {"tenantId": "0",
|
return {"tenantId": "0",
|
||||||
|
@ -43,7 +49,7 @@ class requestsResponse(object):
|
||||||
|
|
||||||
class TestHipchat(unittest.TestCase):
|
class TestHipchat(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.trap = Queue.Queue()
|
self.trap = queue.Queue()
|
||||||
self.hipchat_config = {'timeout': 50}
|
self.hipchat_config = {'timeout': 50}
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
|
@ -15,14 +15,20 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import mock
|
import mock
|
||||||
import Queue
|
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from monasca_notification import notification as m_notification
|
from monasca_notification import notification as m_notification
|
||||||
from monasca_notification.plugins import pagerduty_notifier
|
from monasca_notification.plugins import pagerduty_notifier
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
import Queue as queue
|
||||||
|
else:
|
||||||
|
import queue
|
||||||
|
|
||||||
|
|
||||||
def alarm(metrics):
|
def alarm(metrics):
|
||||||
return {"tenantId": "0",
|
return {"tenantId": "0",
|
||||||
|
@ -45,7 +51,7 @@ class requestsResponse(object):
|
||||||
|
|
||||||
class TestWebhook(unittest.TestCase):
|
class TestWebhook(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.trap = Queue.Queue()
|
self.trap = queue.Queue()
|
||||||
self.pagerduty_config = {'timeout': 50, 'key': 'foobar'}
|
self.pagerduty_config = {'timeout': 50, 'key': 'foobar'}
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
|
@ -15,13 +15,19 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import mock
|
import mock
|
||||||
import Queue
|
|
||||||
import requests
|
import requests
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from monasca_notification import notification as m_notification
|
from monasca_notification import notification as m_notification
|
||||||
from monasca_notification.plugins import webhook_notifier
|
from monasca_notification.plugins import webhook_notifier
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
import Queue as queue
|
||||||
|
else:
|
||||||
|
import queue
|
||||||
|
|
||||||
|
|
||||||
def alarm(metrics):
|
def alarm(metrics):
|
||||||
return {"tenantId": "0",
|
return {"tenantId": "0",
|
||||||
|
@ -46,7 +52,7 @@ class requestsResponse(object):
|
||||||
|
|
||||||
class TestWebhook(unittest.TestCase):
|
class TestWebhook(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.trap = Queue.Queue()
|
self.trap = queue.Queue()
|
||||||
self.webhook_config = {'timeout': 50}
|
self.webhook_config = {'timeout': 50}
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
33
tox.ini
33
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist = {py27,py35,pypy}-{mysql,postgres},pep8,cover
|
envlist = {py27,py35,pypy}-{mysql,postgres},pep8,cover
|
||||||
minversion = 2.1
|
minversion = 2.5
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
@ -22,29 +22,12 @@ whitelist_externals = bash
|
||||||
rm
|
rm
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
PyMySQL>=0.6.1
|
|
||||||
commands =
|
commands =
|
||||||
find . -type f -name "*.pyc" -delete
|
find . -type f -name "*.pyc" -delete
|
||||||
|
rm -Rf .testrepository/times.dbm
|
||||||
ostestr {posargs}
|
ostestr {posargs}
|
||||||
|
|
||||||
[testenv:py27-postgres]
|
|
||||||
deps = -r{toxinidir}/requirements.txt
|
|
||||||
-r{toxinidir}/test-requirements.txt
|
|
||||||
psycopg2>=2.5
|
|
||||||
|
|
||||||
[testenv:py35-postgres]
|
|
||||||
deps = -r{toxinidir}/requirements.txt
|
|
||||||
-r{toxinidir}/test-requirements.txt
|
|
||||||
psycopg2>=2.5
|
|
||||||
|
|
||||||
[testenv:pypy-postgres]
|
|
||||||
deps = -r{toxinidir}/requirements.txt
|
|
||||||
-r{toxinidir}/test-requirements.txt
|
|
||||||
psycopg2>=2.5
|
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
basepython = python2.7
|
|
||||||
deps = {[testenv]deps}
|
|
||||||
commands =
|
commands =
|
||||||
{[testenv]commands}
|
{[testenv]commands}
|
||||||
coverage erase
|
coverage erase
|
||||||
|
@ -56,11 +39,9 @@ commands =
|
||||||
oslo_debug_helper -t ./monasca_notification/tests {posargs}
|
oslo_debug_helper -t ./monasca_notification/tests {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
deps =
|
|
||||||
{[testenv]deps}
|
|
||||||
commands =
|
commands =
|
||||||
{[testenv:flake8]commands}
|
{[testenv:flake8]commands}
|
||||||
{[bandit]commands}
|
{[testenv:bandit]commands}
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
@ -69,6 +50,10 @@ commands = {posargs}
|
||||||
commands =
|
commands =
|
||||||
flake8 monasca_notification
|
flake8 monasca_notification
|
||||||
|
|
||||||
|
[testenv:bandit]
|
||||||
|
commands =
|
||||||
|
bandit -r monasca_notification -n5 -x monasca_notification/tests
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
# TODO: ignored checks should be enabled in the future
|
# TODO: ignored checks should be enabled in the future
|
||||||
|
@ -76,7 +61,3 @@ max-line-length = 120
|
||||||
# H405 multi line docstring summary not separated with an empty line
|
# H405 multi line docstring summary not separated with an empty line
|
||||||
ignore = F821,H201,H405
|
ignore = F821,H201,H405
|
||||||
exclude=.venv,.git,.tox,dist,*egg,build
|
exclude=.venv,.git,.tox,dist,*egg,build
|
||||||
|
|
||||||
[bandit]
|
|
||||||
commands =
|
|
||||||
bandit -r monasca_notification -n5 -x monasca_notification/tests
|
|
||||||
|
|
Loading…
Reference in New Issue