Skip to content

Commit

Permalink
Fix the query tool issue where raise Notice from func/proc or code bl…
Browse files Browse the repository at this point in the history
…ocks are no longer displayed live. #6420
  • Loading branch information
khushboovashi authored Aug 7, 2023
1 parent 27c7ea2 commit b55164c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
3 changes: 3 additions & 0 deletions web/pgadmin/tools/sqleditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 26 additions & 17 deletions web/pgadmin/tools/sqleditor/tests/test_poll_query_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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):
Expand Down Expand Up @@ -82,7 +80,6 @@ def runTest(self):
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
Expand All @@ -94,20 +91,32 @@ def runTest(self):
content_type='html/json')

self.assertEqual(response.status_code, 200)

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'))

if self.expected_message[cnt] is not None:
self.assertIn(self.expected_message[cnt],
response_data['data']['additional_messages'])

# Check the output
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][0][0])
url = '/sqleditor/poll/{0}'.format(self.trans_id)

_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 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']:

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

Expand Down

0 comments on commit b55164c

Please sign in to comment.