Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Fix heartbeat #109

Merged
merged 2 commits into from
Mar 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cliquet/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_backend_error_is_raised_anywhere(self):
for call in calls:
self.assertRaises(exceptions.BackendError, *call)

def test_ping_returns_an_error_if_unavailable(self):
def test_ping_returns_false_if_unavailable(self):
self.client_error_patcher.start()
self.assertFalse(self.cache.ping())

Expand Down
8 changes: 4 additions & 4 deletions cliquet/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_backend_error_is_raised_anywhere(self):
for call in calls:
self.assertRaises(exceptions.BackendError, *call)

def test_ping_returns_an_error_if_unavailable(self):
def test_ping_returns_false_if_unavailable(self):
self.client_error_patcher.start()
self.assertFalse(self.storage.ping())

Expand Down Expand Up @@ -709,7 +709,7 @@ def test_raises_backend_error_if_error_occurs_on_client(self):
def test_backend_error_is_raised_anywhere(self):
pass

def test_ping_returns_an_error_if_unavailable(self):
def test_ping_returns_false_if_unavailable(self):
pass

def test_default_generator(self):
Expand All @@ -732,8 +732,8 @@ def __init__(self, *args, **kwargs):
'execute_command',
side_effect=redis.RedisError)

def test_ping_returns_an_error_if_unavailable(self):
StorageTest.test_ping_returns_an_error_if_unavailable(self)
def test_ping_returns_false_if_unavailable(self):
StorageTest.test_ping_returns_false_if_unavailable(self)

def test_backend_error_provides_original_exception(self):
StorageTest.test_backend_error_provides_original_exception(self)
Expand Down
2 changes: 1 addition & 1 deletion cliquet/tests/test_views_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def test_returns_database_true_if_ok(self):
@mock.patch('cliquet.storage.redis.Redis.ping')
def test_returns_database_false_if_ko(self, *mocked):
for mock_instance in mocked:
mock_instance.side_effect = IndexError
mock_instance.return_value = False
response = self.app.get('/__heartbeat__', status=503)
self.assertEqual(response.json['database'], False)
6 changes: 1 addition & 5 deletions cliquet/views/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
@heartbeat.get(permission=NO_PERMISSION_REQUIRED)
def get_heartbeat(request):
"""Return information about server health."""
try:
request.db.ping()
database = True
except:
database = False
database = request.db.ping()

status = dict(database=database)
has_error = not all([v for v in status.values()])
Expand Down