Skip to content

Commit

Permalink
Added test for authenticated redis instance. Added command for travis…
Browse files Browse the repository at this point in the history
… to run an authenticated redis instance
  • Loading branch information
dfezzie committed Apr 24, 2017
1 parent fd31a1f commit bdf4ac1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ install:
- pip install coverage coveralls Mako
before_script:
- redis-server --port 6399 &
- redis-server --port 6400 &
- redis-cli -p 6400 config set requirepass foobared
script: py.test --cov flask_bitmapist --cov-report term-missing --pep8 --flakes
after_success:
- coveralls
Expand Down
12 changes: 11 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def app(request):
app = Flask(__name__)
app.debug = True
app.config['TESTING'] = True
# app.config['BITMAPIST_REDIS_URL'] = 'redis://localhost:6379'
app.config['BITMAPIST_REDIS_URL'] = 'redis://localhost:6399'
app.config['SECRET_KEY'] = 'secret'
app.config['SECRET_KEY'] = 'verysecret'
Expand Down Expand Up @@ -131,3 +130,14 @@ def teardown():
request.addfinalizer(teardown)
# TODO: may return just db with tests using sqlalchemy_user fixture directly
return db, sqlalchemy_user


@pytest.fixture
def auth_bitmap():
app = Flask(__name__)
app.config['BITMAPIST_REDIS_URL'] = 'redis://localhost:6400'
app.config['BITMAPIST_REDIS_PASSWORD'] = 'foobared'
app.config['SECRET_KEY'] = 'secret'
app.config['SECRET_KEY'] = 'verysecret'
auth_bitmap = FlaskBitmapist(app)
return auth_bitmap
13 changes: 13 additions & 0 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,16 @@ def test_unmark_function(app, client):

unmark_event('active', 126)
assert 126 not in MonthEvents('active', now.year, now.month)


def test_authenticated_redis(app, auth_bitmap):
assert auth_bitmap.redis_auth == 'foobared'

# Test to make sure auth_bitmap setup with different set of params
assert auth_bitmap.redis_url != app.config['BITMAPIST_REDIS_URL']

mark_event('active', 42)
assert 42 in MonthEvents('active', now.year, now.month)

unmark_event('active', 42)
assert 42 not in MonthEvents('active', now.year, now.month)

0 comments on commit bdf4ac1

Please sign in to comment.