Exemplo n.º 1
0
 def test_heartbeat_return_true_if_token_server_is_working(self):
     with mock.patch('syncto.heartbeat.requests.get') as mocked_request:
         mocked_request.return_value.raise_for_status.return_value = None
         request = mock.MagicMock()
         request.registry.settings = {
             'token_server_url': 'https://example.com',
             'token_server_heartbeat_timeout_seconds': 5
         }
         self.assertTrue(ping_sync_cluster(request))
         mocked_request.assert_called_with(
             'https://example.com/__heartbeat__', timeout=5)
Exemplo n.º 2
0
 def test_heartbeat_return_true_if_token_server_is_working(self):
     with mock.patch('syncto.heartbeat.requests.get') as mocked_request:
         mocked_request.return_value.raise_for_status.return_value = None
         request = mock.MagicMock()
         request.registry.settings = {
             'token_server_url': 'https://example.com',
             'token_server_heartbeat_timeout_seconds': 5
         }
         self.assertTrue(ping_sync_cluster(request))
         mocked_request.assert_called_with(
             'https://example.com/__heartbeat__', timeout=5)
Exemplo n.º 3
0
 def test_heartbeat_return_false_if_token_server_outofservice(self):
     with mock.patch('syncto.heartbeat.requests.get') as mocked_request:
         mocked_request.return_value.raise_for_status.side_effect = (
             HTTPError())
         request = mock.MagicMock()
         request.registry.settings = {
             'token_server_url': 'https://example.com',
             'token_server_heartbeat_timeout_seconds': 5
         }
         self.assertFalse(ping_sync_cluster(request))
         mocked_request.assert_called_with(
             'https://example.com/__heartbeat__', timeout=5)
Exemplo n.º 4
0
 def test_heartbeat_return_false_if_token_server_outofservice(self):
     with mock.patch('syncto.heartbeat.requests.get') as mocked_request:
         mocked_request.return_value.raise_for_status.side_effect = (
             HTTPError())
         request = mock.MagicMock()
         request.registry.settings = {
             'token_server_url': 'https://example.com',
             'token_server_heartbeat_timeout_seconds': 5
         }
         self.assertFalse(ping_sync_cluster(request))
         mocked_request.assert_called_with(
             'https://example.com/__heartbeat__', timeout=5)