def test_modulestore_fail(self): with patch('openedx.core.djangoapps.heartbeat.views.modulestore' ) as mock_modulestore: mock_modulestore.return_value.heartbeat.side_effect = HeartbeatFailure( 'msg', 'service') response = self.client.get(self.heartbeat_url) self.assertEqual(response.status_code, 503)
def heartbeat(self): """ Check that the db is reachable. """ if self.database.connection.alive(): return True else: raise HeartbeatFailure("Can't connect to {}".format(self.database.name))
def heartbeat(self): """ Check that the db is reachable. """ try: # The ismaster command is cheap and does not require auth. self.database.client.admin.command('ismaster') return True except pymongo.errors.ConnectionFailure: raise HeartbeatFailure(f"Can't connect to {self.database.name}", 'mongo') # lint-amnesty, pylint: disable=raise-missing-from
def heartbeat(self): """ Check that the db is reachable. """ try: # The ismaster command is cheap and does not require auth. self.database.client.admin.command('ismaster') return True except pymongo.errors.ConnectionFailure: raise HeartbeatFailure("Can't connect to {}".format(self.database.name), 'mongo')
def test_modulestore_fail(self, mock_modulestore): # pylint: disable=unused-argument mock_modulestore.return_value.heartbeat.side_effect = HeartbeatFailure( 'msg', 'service') response = self.client.get(self.heartbeat_url) self.assertEqual(response.status_code, 503)