Skip to content

Commit

Permalink
Using mockredispy
Browse files Browse the repository at this point in the history
  • Loading branch information
carlomorelli committed Jun 18, 2016
1 parent 49ee70b commit 2f1544a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ mock
nose
flask
redis
mockredispy
16 changes: 10 additions & 6 deletions tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import mock
import redis
import acrewstic
import mockredis


class TestRestApi:
Expand All @@ -16,12 +17,15 @@ def setup_class(self):
def teardown_class(self):
print "Shutting down application..."

@mock.patch.object(redis.StrictRedis, 'info')
def test_0_get_version(self, mock_info):
# result = self.client.get('/acrewstic/version')
# assert result.status_code == 200
self.client.get('/acrewstic/version')
mock_info.assert_called()
@mock.patch('redis.StrictRedis', mockredis.mock_strict_redis_client)
def test_0_get_version(self):
# mock_info.return_value = json.dumps({'version': 'fakeRedis'})
result = self.client.get('/acrewstic/version')
assert result.status_code == 200
# mock_info.assert_called()
data = json.loads(result.data)
print data
# assert data['redis_info']['version'] == 'fakeRedis'

def test_1_get_tasks(self):
result = self.client.get('/acrewstic/tasks')
Expand Down

0 comments on commit 2f1544a

Please sign in to comment.