コード例 #1
0
 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)
コード例 #2
0
 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))
コード例 #3
0
 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
コード例 #4
0
 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')
コード例 #5
0
 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)