From a0ff0e30fbb8bc23f5f1a80dd2ea4238062ebc82 Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Thu, 17 Dec 2020 18:59:44 +0530 Subject: [PATCH] Fixed Debugger API test cases. refs #5343 --- .../test_debugger_clear_all_breakpoint.py | 4 ++-- .../tests/test_debugger_execute_query.py | 4 ++-- .../test_debugger_poll_execution_result.py | 4 ++-- .../tests/test_debugger_poll_result.py | 2 +- .../tests/test_debugger_set_breakpoint.py | 4 ++-- .../tests/test_start_execution_debugger.py | 2 +- web/pgadmin/tools/debugger/tests/utils.py | 18 +++++++++++++++--- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/web/pgadmin/tools/debugger/tests/test_debugger_clear_all_breakpoint.py b/web/pgadmin/tools/debugger/tests/test_debugger_clear_all_breakpoint.py index 56db948cf..4c8fcaf4d 100644 --- a/web/pgadmin/tools/debugger/tests/test_debugger_clear_all_breakpoint.py +++ b/web/pgadmin/tools/debugger/tests/test_debugger_clear_all_breakpoint.py @@ -51,9 +51,9 @@ class DebuggerClearAllBreakpoint(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) self.port_no = debugger_utils.messages(self, utils, db_utils) - debugger_utils.start_execution(self) + debugger_utils.start_execution(self, utils, db_utils) breakpoint = debugger_utils.set_breakpoint(self) def clear_all_breakpoint(self): diff --git a/web/pgadmin/tools/debugger/tests/test_debugger_execute_query.py b/web/pgadmin/tools/debugger/tests/test_debugger_execute_query.py index a6ff8ef21..02599369d 100644 --- a/web/pgadmin/tools/debugger/tests/test_debugger_execute_query.py +++ b/web/pgadmin/tools/debugger/tests/test_debugger_execute_query.py @@ -49,10 +49,10 @@ class DebuggerExecuteQuery(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) self.port_no = debugger_utils.messages(self, utils, db_utils) - debugger_utils.start_execution(self) + debugger_utils.start_execution(self, utils, db_utils) def execute_query(self): return self.tester.get( diff --git a/web/pgadmin/tools/debugger/tests/test_debugger_poll_execution_result.py b/web/pgadmin/tools/debugger/tests/test_debugger_poll_execution_result.py index 376d1e4ed..cf66fa4fb 100644 --- a/web/pgadmin/tools/debugger/tests/test_debugger_poll_execution_result.py +++ b/web/pgadmin/tools/debugger/tests/test_debugger_poll_execution_result.py @@ -51,9 +51,9 @@ class DebuggerPollExecutionResult(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) self.port_no = debugger_utils.messages(self, utils, db_utils) - debugger_utils.start_execution(self) + debugger_utils.start_execution(self, utils, db_utils) def poll_execution_result(self): return self.tester.get( diff --git a/web/pgadmin/tools/debugger/tests/test_debugger_poll_result.py b/web/pgadmin/tools/debugger/tests/test_debugger_poll_result.py index d465d527b..e92e9b276 100644 --- a/web/pgadmin/tools/debugger/tests/test_debugger_poll_result.py +++ b/web/pgadmin/tools/debugger/tests/test_debugger_poll_result.py @@ -51,7 +51,7 @@ class DebuggerPollResult(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) def execute_query(self): return self.tester.get( diff --git a/web/pgadmin/tools/debugger/tests/test_debugger_set_breakpoint.py b/web/pgadmin/tools/debugger/tests/test_debugger_set_breakpoint.py index 82b6b0a5e..af4a6dab3 100644 --- a/web/pgadmin/tools/debugger/tests/test_debugger_set_breakpoint.py +++ b/web/pgadmin/tools/debugger/tests/test_debugger_set_breakpoint.py @@ -51,9 +51,9 @@ class DebuggerSetBreakpoint(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) self.port_no = debugger_utils.messages(self, utils, db_utils) - debugger_utils.start_execution(self) + debugger_utils.start_execution(self, utils, db_utils) if self.query_type == 2: debugger_utils.set_breakpoint(self) diff --git a/web/pgadmin/tools/debugger/tests/test_start_execution_debugger.py b/web/pgadmin/tools/debugger/tests/test_start_execution_debugger.py index e35a031dd..f416c329b 100644 --- a/web/pgadmin/tools/debugger/tests/test_start_execution_debugger.py +++ b/web/pgadmin/tools/debugger/tests/test_start_execution_debugger.py @@ -51,7 +51,7 @@ class DebuggerStartExecution(BaseTestGenerator): if self.init_target: debugger_utils.initialize_target(self, utils) - debugger_utils.start_listener(self) + debugger_utils.start_listener(self, utils, db_utils) self.port_no = debugger_utils.messages(self, utils, db_utils) def start_execution(self): diff --git a/web/pgadmin/tools/debugger/tests/utils.py b/web/pgadmin/tools/debugger/tests/utils.py index e4acc65f1..a56f3665f 100644 --- a/web/pgadmin/tools/debugger/tests/utils.py +++ b/web/pgadmin/tools/debugger/tests/utils.py @@ -126,11 +126,16 @@ def initialize_target(self, utils, close_debugger_instance=True): 'for indirect debugging.') -def start_listener(self): +def start_listener(self, utils, db_utils): response = self.tester.get( 'debugger/start_listener/' + str(self.trans_id), content_type='application/json') - + if response.status_code != 200: + close_debugger(self) + delete_function(self, utils) + db_utils.disconnect_database( + self, self.server_id, self.db_id) + self.skipTest('Debugger is in Busy state.') self.assertEqual(response.status_code, 200) @@ -163,11 +168,18 @@ def messages(self, utils, db_utils): return port -def start_execution(self): +def start_execution(self, utils, db_utils): response = self.tester.get( 'debugger/start_execution/' + str(self.trans_id) + '/' + str( self.port_no), content_type='application/json') + if response.status_code != 200: + close_debugger(self) + delete_function(self, utils) + db_utils.disconnect_database( + self, self.server_id, self.db_id) + self.skipTest('Debugger is in Busy state.') + self.assertEqual(response.status_code, 200)