Skip to content

Commit

Permalink
Update .travis.yml and tests to deal with older versions of python
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Wilson committed Jan 19, 2019
1 parent 4d2e3ef commit 72c2b22
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 24 deletions.
46 changes: 36 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"

matrix:
include:
- python: 2.6
env:
- WITH_JWT=false
WITH_HAWK=true
- python: 2.7
env:
- WITH_JWT=true
WITH_HAWK=true
- python: 3.3
env:
- WITH_JWT=false
WITH_HAWK=false
SETUPTOOLS="setuptools<40.0.0"
- python: 3.4
env:
- WITH_JWT=true
WITH_HAWK=true
- python: 3.5
env:
- WITH_JWT=true
WITH_HAWK=true
- python: 3.6
env:
- WITH_JWT=true
WITH_HAWK=true

before_install:
- pip install --upgrade pytest

install: "pip install -r requirements-dev.txt"
install:
- "[[ -n \"$SETUPTOOLS\" ]] && pip install "$SETUPTOOLS" || true"
- pip install -r requirements-dev.txt
- $WITH_JWT && pip install pyjwt>=1.7.0 || true
- $WITH_HAWK && pip install mohawk>=1.0.0 || true

script: py.test --cov-report term-missing --cov=falcon_auth
script:
- py.test --cov-report term-missing --cov=falcon_auth

after_success:
- coveralls
- coveralls
4 changes: 0 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ tox==2.3.1
codecov==2.0.3
coverage==4.0.3
python-coveralls==2.9.0

# Optional dependencies
pyjwt
mohawk==1.0.0
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
from setuptools import setup

version = '1.1.0'
version = '1.2.0'

if sys.argv[-1] == 'tag':
os.system("git tag -a %s -m 'version %s'" % (version, version))
Expand All @@ -32,19 +32,22 @@
os.system('py.test')
sys.exit()

# From docs for pytest-runner
needs_pytest = any(arg in ['pytest', 'test', 'ptr'] for arg in sys.argv)
setup_requires = ['pytest-runner'] if needs_pytest else []

setup(
author='Ritesh Kadmawala',
author_email='ritesh@loanzen.in',
description='falcon-auth',
download_url='',
setup_requires=['pytest-runner'],
setup_requires=setup_requires,
install_requires=[
'falcon'
],
extras_require={
'backend-hawk': ['mohawk==1.0.0'],
'backend-jwt': ['pyjwt']
'backend-hawk': ['mohawk>=1.0.0,<2.0.0'],
'backend-jwt': ['pyjwt>=1.7.1,<2.0.0']
},
license='MIT',
name='falcon-auth',
Expand All @@ -60,9 +63,7 @@
'codecov>=2.0.3,<3.0.0',
'coverage>=4.0.3,<5.0.0',
'tox>=2.3.1,<3.0.0',
'python-coveralls==2.9.0',
'pyjwt',
'mohawk==1.0.0',
'python-coveralls>=2.9.1,<3.0.0'
],
url='https://github.com/loanzen/falcon-auth',
version=version
Expand Down
13 changes: 11 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from datetime import datetime, timedelta

import falcon
import jwt
import mohawk
import pytest
from falcon import testing

Expand All @@ -21,6 +19,17 @@
from falcon_auth.backends import TokenAuthBackend
from falcon_auth.serializer import ExtendedJSONEncoder

try:
import jwt
jwt_available = pytest.mark.skipif(False, reason="jwt not installed")
except ImportError:
jwt_available = pytest.mark.skipif(True, reason="jwt not installed")

try:
import mohawk
hawk_available = pytest.mark.skipif(False, reason="hawk not installed")
except ImportError:
hawk_available = pytest.mark.skipif(True, reason="hawk not installed")

EXPIRATION_DELTA = 30 * 60

Expand Down
5 changes: 4 additions & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def test_backend_get_auth_token(self, user, backend, auth_token):
assert backend.get_auth_token(user_payload) == auth_token


@jwt_available
class TestWithJWTAuth(JWTAuthFixture, ResourceFixture):

def test_get_auth_header(self, jwt_backend, user):
Expand Down Expand Up @@ -161,6 +162,7 @@ def test_backend_get_auth_token(self, user, backend):
assert decoded_token['user'] == user_payload


@hawk_available
class TestWithHawkAuth(HawkAuthFixture, ResourceFixture):

def test_valid_auth_success(self, client, auth_token, user):
Expand Down Expand Up @@ -311,12 +313,13 @@ def test_auth_middleware_none_backend():

assert 'Invalid authentication backend' in str(ex.value)


@jwt_available
def test_optional_jwt_not_present(monkeypatch):
monkeypatch.delattr('falcon_auth.backends.jwt')
with pytest.raises(ImportError):
JWTAuthBackend(lambda _: None, SECRET_KEY)

@hawk_available
def test_optional_hawk_not_present(monkeypatch):
monkeypatch.delattr('falcon_auth.backends.mohawk')
with pytest.raises(ImportError):
Expand Down

0 comments on commit 72c2b22

Please sign in to comment.