Fix the query tool issue where raise Notice from func/proc or code blocks are no longer displayed live. #6420

This commit is contained in:
Khushboo Vashi 2023-08-07 17:19:08 +05:30 committed by GitHub
parent 27c7ea2ff1
commit b55164c454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 14 deletions

View File

@ -927,6 +927,9 @@ def poll(trans_id):
if is_thread_alive:
status = 'Busy'
messages = conn.messages()
if messages and len(messages) > 0:
result = ''.join(messages)
elif status and conn is not None and session_obj is not None:
status, result = conn.poll(
formatted_exception_msg=True, no_result=True)

View File

@ -15,8 +15,6 @@ from pgadmin.utils.route import BaseTestGenerator
from regression import parent_node_dict
from regression.python_test_utils import test_utils as utils
import secrets
from pgadmin.tools.sqleditor.tests.execute_query_test_utils \
import async_poll
class TestPollQueryTool(BaseTestGenerator):
@ -82,7 +80,6 @@ NOTICE: Hello, world!
url = '/sqleditor/initialize/sqleditor/{0}/{1}/{2}/{3}'.format(
self.trans_id, utils.SERVER_GROUP, self.server_id, self.db_id)
response = self.tester.post(url)
import time
self.assertEqual(response.status_code, 200)
cnt = 0
@ -94,20 +91,32 @@ NOTICE: Hello, world!
content_type='html/json')
self.assertEqual(response.status_code, 200)
url = '/sqleditor/poll/{0}'.format(self.trans_id)
response = async_poll(tester=self.tester,
poll_url='/sqleditor/poll/{0}'.format(
self.trans_id))
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.data.decode('utf-8'))
_status = True
# Lets poll till the status is busy and check the messages
while _status:
response = self.tester.get(url)
if response.data:
response_data = json.loads(response.data.decode('utf-8'))
if self.expected_message[cnt] is not None:
self.assertIn(self.expected_message[cnt],
response_data['data']['additional_messages'])
if response_data['success'] == 1 and 'data' in\
response_data:
if response_data['data']['status'] == 'NotInitialised':
pass
elif response_data['data']['status'] == 'Busy':
if self.expected_message[cnt] is not None:
if response_data['data']['result']:
# Check the output
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][0][0])
self.assertIn(
response_data['data']['result'],
self.expected_message[cnt]
)
else:
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][
0][0])
_status = False
cnt += 1