Skip to content

Commit

Permalink
switched from mockredis to fakeredis
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidwhiteside committed Feb 6, 2021
1 parent 4e3cf23 commit c92f77a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ before_install:
# - sudo apt-get install libcurl4-gnutls-dev

install:
- pip install nose flask flask-redis mockredispy coveralls PyYAML PyJWT
- pip install nose flask flask-redis fakeredis coveralls PyYAML PyJWT

# Run Tests
script:
Expand Down
2 changes: 1 addition & 1 deletion pivportal/lib/pivportal/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def create_app():
app = Flask(__name__)
redis_store = FlaskRedis()
redis_store = FlaskRedis(decode_responses=True)
redis_store.init_app(app)
return (app, redis_store)

Expand Down
13 changes: 3 additions & 10 deletions pivportal/test/test_pivportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@
class TestCli(unittest.TestCase):

def setUp(self):
from flask_redis import FlaskRedis
from mockredis import MockRedis
class MockRedisWrapper(MockRedis):
'''A wrapper to add the `from_url` classmethod'''
@classmethod
def from_url(cls, *args, **kwargs):
return cls()
pivportal.rest.redis_store = FlaskRedis.from_custom_provider(MockRedisWrapper)
pivportal.rest.redis_store.init_app(pivportal.rest.app)
import fakeredis
pivportal.rest.redis_store = fakeredis.FakeRedis(decode_responses=True)

def test_dn_is_valid_withinvalidchars(self):
assert pivportal.security.dn_is_valid("%#DW;$%&*") == False
Expand Down Expand Up @@ -179,4 +172,4 @@ def test_valid_client_cert_required_notvaliduser(self):
def test_valid_client_cert_required_invalidusername(self):
pivportal.security.dn_to_username = {'test_dn1': "testuser1.$#@#"}
result = pivportal.rest.app.test_client().post("/api/rest/user/login", headers={'SSL_CLIENT_S_DN': 'testuser1.$#@#'})
assert result.status_code == 400
assert result.status_code == 400

0 comments on commit c92f77a

Please sign in to comment.