def test_check_success_fail(self, mock_sleep): old_retry_timeout = server.RETRY_TIMEOUT server.RETRY_TIMEOUT = SLEEP_INTERVAL + 1 client_mock = MagicMock(PrestoClient) client_mock.execute_query.side_effect = [False, False] self.assertEqual(server.check_server_status(client_mock), False) server.RETRY_TIMEOUT = old_retry_timeout
def test_check_success_status(self, mock_run_sql, string_config_mock, mock_run, mock_presto_config): env.roledefs = { 'coordinator': ['Node1'], 'worker': ['Node1', 'Node2', 'Node3', 'Node4'], 'all': ['Node1', 'Node2', 'Node3', 'Node4'] } env.hosts = env.roledefs['all'] env.host = 'Node1' string_config_mock.return_value = 'Node1' mock_run_sql.return_value = [['Node2', 'some stuff'], ['Node1', 'some other stuff']] self.assertEqual(server.check_server_status(), True)
def test_check_success_fail(self, mock_query_for_status, string_config_mock, mock_run): env.roledefs = { 'coordinator': ['Node1'], 'worker': ['Node1', 'Node2', 'Node3', 'Node4'], 'all': ['Node1', 'Node2', 'Node3', 'Node4'] } env.hosts = env.roledefs['all'] env.host = 'Node1' string_config_mock.return_value = 'Node1' mock_query_for_status.return_value = False self.assertEqual(server.check_server_status(), False)
def test_check_success_status(self, mock_sleep): client_mock = MagicMock(PrestoClient) client_mock.execute_query.side_effect = [False, True] self.assertEqual(server.check_server_status(client_mock), True)