commit
173f33f66e
6 changed files with 18 additions and 7 deletions
|
@ -1,8 +1,6 @@
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- "2.6"
|
|
||||||
- "2.7"
|
- "2.7"
|
||||||
- "3.3"
|
|
||||||
- "3.4"
|
- "3.4"
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.6"
|
- "3.6"
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
pytest==3.5.1
|
||||||
|
pytest-cov==2.5.1
|
||||||
|
mockredispy==2.9.3
|
||||||
coverage==4.2
|
coverage==4.2
|
||||||
flake8==3.0.4
|
flake8==3.0.4
|
||||||
tox==2.3.1
|
tox==3.0.0
|
||||||
|
|
|
@ -5,3 +5,4 @@ Werkzeug==0.9.4
|
||||||
itsdangerous==0.23
|
itsdangerous==0.23
|
||||||
redis==2.8.0
|
redis==2.8.0
|
||||||
cryptography==1.8.1
|
cryptography==1.8.1
|
||||||
|
mock==1.0.1
|
||||||
|
|
|
@ -27,7 +27,10 @@ app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key')
|
||||||
app.config.update(
|
app.config.update(
|
||||||
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
|
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
|
||||||
|
|
||||||
if os.environ.get('REDIS_URL'):
|
if os.environ.get('MOCK_REDIS'):
|
||||||
|
from mockredis import mock_strict_redis_client
|
||||||
|
redis_client = mock_strict_redis_client()
|
||||||
|
elif os.environ.get('REDIS_URL'):
|
||||||
redis_client = redis.StrictRedis.from_url(os.environ.get('REDIS_URL'))
|
redis_client = redis.StrictRedis.from_url(os.environ.get('REDIS_URL'))
|
||||||
else:
|
else:
|
||||||
redis_host = os.environ.get('REDIS_HOST', 'localhost')
|
redis_host = os.environ.get('REDIS_HOST', 'localhost')
|
||||||
|
|
6
tests.py
6
tests.py
|
@ -1,3 +1,4 @@
|
||||||
|
from mock import patch
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -5,6 +6,7 @@ from unittest import TestCase
|
||||||
|
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
from werkzeug.exceptions import BadRequest
|
from werkzeug.exceptions import BadRequest
|
||||||
|
from mockredis import mock_strict_redis_client
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
import snappass.main as snappass
|
import snappass.main as snappass
|
||||||
|
@ -14,6 +16,7 @@ __author__ = 'davedash'
|
||||||
|
|
||||||
class SnapPassTestCase(TestCase):
|
class SnapPassTestCase(TestCase):
|
||||||
|
|
||||||
|
@patch('redis.client.StrictRedis', mock_strict_redis_client)
|
||||||
def test_get_password(self):
|
def test_get_password(self):
|
||||||
password = "melatonin overdose 1337!$"
|
password = "melatonin overdose 1337!$"
|
||||||
key = snappass.set_password(password, 30)
|
key = snappass.set_password(password, 30)
|
||||||
|
@ -91,6 +94,9 @@ class SnapPassTestCase(TestCase):
|
||||||
password = 'open sesame'
|
password = 'open sesame'
|
||||||
key = snappass.set_password(password, 1)
|
key = snappass.set_password(password, 1)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
|
# Expire functionality must be explicitly invoked using do_expire(time).
|
||||||
|
# mockredis does not support automatic expiration at this time
|
||||||
|
snappass.redis_client.do_expire()
|
||||||
self.assertEqual(None, snappass.get_password(key))
|
self.assertEqual(None, snappass.get_password(key))
|
||||||
|
|
||||||
|
|
||||||
|
|
6
tox.ini
6
tox.ini
|
@ -2,11 +2,11 @@
|
||||||
envlist = py27, py34, py35, py36, flake8
|
envlist = py27, py34, py35, py36, flake8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
setenv =
|
||||||
pytest
|
MOCK_REDIS = 1
|
||||||
pytest-cov
|
|
||||||
commands =
|
commands =
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
pip install -r dev-requirements.txt
|
||||||
py.test --junitxml=junit-{envname}.xml --cov-report xml tests.py
|
py.test --junitxml=junit-{envname}.xml --cov-report xml tests.py
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
|
|
Loading…
Reference in a new issue