Skip to content

Commit 48df341

Browse files
committed
Rework project structure
Closes #14
1 parent 95e52cd commit 48df341

File tree

8 files changed

+34
-20
lines changed

8 files changed

+34
-20
lines changed
File renamed without changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
download_url='https://github.com/underyx/flask-redis/releases',
2222
description='Redis Extension for Flask Applications',
2323
long_description=README + '\n\n' + HISTORY,
24-
py_modules=['flask_redis'],
24+
packages=['flask_redis'],
2525
package_data={'': ['LICENSE']},
2626
zip_safe=False,
2727
install_requires=[

test/__init__.py

Whitespace-only changes.

test/integration/__init__.py

Whitespace-only changes.

test_flask_redis.py renamed to test/integration/test_flask_redis.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
4-
"""Tests for Flask-Redis."""
3+
"""Integration tests for Flask-Redis."""
54

65
import flask
76
from flask_redis import FlaskRedis
@@ -14,19 +13,19 @@ def app():
1413

1514

1615
def test_constructor(app):
17-
'''Test that a constructor with app instance will initialize the
18-
connection'''
16+
"""Test that a constructor with app instance will initialize the
17+
connection"""
1918
redis = FlaskRedis(app)
2019
assert redis._redis_client is not None
2120
assert hasattr(redis._redis_client, 'connection_pool')
2221

2322

2423
def test_init_app(app):
25-
'''Test that a constructor without app instance will not initialize the
24+
"""Test that a constructor without app instance will not initialize the
2625
connection.
2726
2827
After FlaskRedis.init_app(app) is called, the connection will be
29-
initialized.'''
28+
initialized."""
3029
redis = FlaskRedis()
3130
assert redis._redis_client is None
3231
redis.init_app(app)
@@ -35,7 +34,7 @@ def test_init_app(app):
3534

3635

3736
def test_custom_prefix(app):
38-
'''Test that config prefixes enable distinct connections'''
37+
"""Test that config prefixes enable distinct connections"""
3938
app.config['DBA_URL'] = 'redis://localhost:6379/1'
4039
app.config['DBB_URL'] = 'redis://localhost:6379/2'
4140
redis_a = FlaskRedis(app, config_prefix='DBA')
@@ -45,8 +44,8 @@ def test_custom_prefix(app):
4544

4645

4746
def test_strict_parameter(app):
48-
'''Test that initializing with the strict parameter set to True will use
49-
StrictRedis, and that False will keep using the old Redis class.'''
47+
"""Test that initializing with the strict parameter set to True will use
48+
StrictRedis, and that False will keep using the old Redis class."""
5049

5150
redis = FlaskRedis(app, strict=True)
5251
assert redis._redis_client is not None
@@ -58,8 +57,8 @@ def test_strict_parameter(app):
5857

5958

6059
def test_custom_provider(app):
61-
'''Test that FlaskRedis can be instructed to use a different Redis client,
62-
like StrictRedis'''
60+
"""Test that FlaskRedis can be instructed to use a different Redis client,
61+
like StrictRedis"""
6362
class FakeProvider(object):
6463

6564
@classmethod

test/unit/__init__.py

Whitespace-only changes.

test/unit/test_flask_redis.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from flask_redis import FlaskRedis
2+
3+
4+
def test_constructor_app(mocker):
5+
"""Test that the constructor passes the app to FlaskRedis.init_app"""
6+
mocker.patch.object(FlaskRedis, 'init_app', autospec=True)
7+
app_stub = mocker.stub(name='app_stub')
8+
9+
FlaskRedis(app_stub)
10+
11+
FlaskRedis.init_app.assert_called_once_with(mocker.ANY, app_stub)

tox.ini

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[tox]
22
envlist =
33
static_analysis,
4-
py27-flask{09,011}-redis{26,210},
5-
py{34,35}-flask011-redis{26,210}
4+
py{27,34,35}-unit_tests,
5+
py27-flask{09,011}-redis{26,210}-integration_tests,
6+
py{34,35}-flask011-redis{26,210}-integration_tests
67

78
[tox:travis]
89
2.7 = py27
@@ -21,10 +22,13 @@ passenv =
2122
TRAVIS_JOB_ID
2223
TRAVIS_BRANCH
2324
deps =
24-
flask09: Flask>=0.9,<0.10
25-
flask011: Flask>=0.11,<0.12
26-
redis26: redis>=2.6,<2.7
27-
redis210: redis>=2.10,<2.11
25+
integration_tests-flask09: Flask>=0.9,<0.10
26+
integration_tests-flask011: Flask>=0.11,<0.12
27+
integration_tests-redis26: redis>=2.6,<2.7
28+
integration_tests-redis210: redis>=2.10,<2.11
2829
pytest
29-
pytest-cov
30-
commands = py.test --cov-report term-missing --cov=flask_redis flask_redis.py test_flask_redis.py
30+
unit_tests: pytest-cov
31+
unit_tests: pytest-mock
32+
commands =
33+
integration_tests: py.test test/integration
34+
unit_tests: py.test --cov-report term-missing --cov=flask_redis test/unit

0 commit comments

Comments
 (0)