From fb1840493bc29146578f619ca2219ce9ecc91013 Mon Sep 17 00:00:00 2001 From: Fred Phillips Date: Sat, 28 Oct 2017 14:48:33 +0100 Subject: [PATCH] Set up continuous integration - add Travis CI - add tox - move tests to own directory - migrate to pytest Signed-off-by: Fred Phillips --- .travis.yml | 10 ++++++++++ setup.py | 2 +- tests/__init__.py | 0 {github_webhook => tests}/test_webhook.py | 22 +++++++++++----------- tox.ini | 23 +++++++++++++++++++++++ 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/__init__.py rename {github_webhook => tests}/test_webhook.py (75%) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..def46e8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "2.7" + - "3.6" + - "pypy" + - "pypy3" +install: + - pip install tox-travis +script: + - tox diff --git a/setup.py b/setup.py index ae11487..94014ff 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ license='Apache 2.0', packages=["github_webhook"], install_requires=['flask', 'six'], - tests_require=['mock', 'nose'], + tests_require=['mock', 'pytest'], classifiers=[ 'Development Status :: 4 - Beta', diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/github_webhook/test_webhook.py b/tests/test_webhook.py similarity index 75% rename from github_webhook/test_webhook.py rename to tests/test_webhook.py index 4df373d..e22b710 100644 --- a/github_webhook/test_webhook.py +++ b/tests/test_webhook.py @@ -2,7 +2,6 @@ from __future__ import print_function -import unittest try: from unittest.mock import Mock except ImportError: @@ -11,18 +10,19 @@ from github_webhook.webhook import Webhook -class TestWebhook(unittest.TestCase): +def test_constructor(): + # GIVEN + app = Mock() - def test_constructor(self): - # GIVEN - app = Mock() + # WHEN + webhook = Webhook(app) - # WHEN - webhook = Webhook(app) - - # THEN - app.add_url_rule.assert_called_once_with( - '/postreceive', view_func=webhook._postreceive, methods=['POST']) + # THEN + app.add_url_rule.assert_called_once_with( + endpoint='/postreceive', + rule='/postreceive', + view_func=webhook._postreceive, + methods=['POST']) # ----------------------------------------------------------------------------- # Copyright 2015 Bloomberg Finance L.P. diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..6d31e34 --- /dev/null +++ b/tox.ini @@ -0,0 +1,23 @@ +[tox] +envlist = py27,py36,pypy,pypy3 + +[testenv] +deps = + pytest + flask + six +commands = pytest -vl + +[testenv:py27] +deps = + pytest + flask + six + mock + +[testenv:pypy] +deps = + pytest + flask + six + mock \ No newline at end of file