public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch] - Test cases failure fix
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch] - Test cases failure fix
@ 2021-06-17 10:27  Khushboo Vashi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Khushboo Vashi @ 2021-06-17 10:27 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

Please find the attached patch to fix the test cases failure due to below
error on PG 9.6.

psycopg2.errors.ObjectInUse: database "test_db_1658f" is being
accessed by other users
DETAIL:  There is 1 other session using the database.

Thanks,
Khushboo


Attachments:

  [application/octet-stream] api_test_cases_failure_fixes.patch (3.8K, 3-api_test_cases_failure_fixes.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
index 2692bc026..161bc9e0e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
@@ -228,8 +228,7 @@ class CheckConstraintView(PGChildNodeView):
         Returns:
 
         """
-        SQL = "END;"
-        self.conn.execute_scalar(SQL)
+        self.conn.execute_void("END;")
 
     @check_precondition
     def list(self, gid, sid, did, scid, tid, cid=None):
@@ -536,8 +535,9 @@ class CheckConstraintView(PGChildNodeView):
             if 'name' not in data or data['name'] == "":
                 sql = "BEGIN;"
                 # Start transaction.
-                status, res = self.conn.execute_scalar(sql)
+                status, res = self.conn.execute_void(sql)
                 if not status:
+                    self.conn.execute_void('ROLLBACK;')
                     self.end_transaction()
                     return internal_server_error(errormsg=res)
 
@@ -549,6 +549,7 @@ class CheckConstraintView(PGChildNodeView):
 
             status, msg = self.conn.execute_scalar(sql)
             if not status:
+                self.conn.execute_void('ROLLBACK;')
                 self.end_transaction()
                 return internal_server_error(errormsg=msg)
 
@@ -561,6 +562,7 @@ class CheckConstraintView(PGChildNodeView):
 
                 status, res = self.conn.execute_dict(sql)
                 if not status:
+                    self.conn.execute_void('ROLLBACK;')
                     self.end_transaction()
                     return internal_server_error(errormsg=res)
 
@@ -576,6 +578,7 @@ class CheckConstraintView(PGChildNodeView):
                 )
                 status, res = self.conn.execute_dict(sql)
                 if not status:
+                    self.conn.execute_void('ROLLBACK;')
                     self.end_transaction()
                     return internal_server_error(errormsg=res)
 
@@ -592,6 +595,7 @@ class CheckConstraintView(PGChildNodeView):
             )
 
         except Exception as e:
+            self.conn.execute_void('ROLLBACK;')
             self.end_transaction()
             return make_json_response(
                 status=400,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json
index 28debaf33..5f8dd7f5f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/tests/check_constraint_test_data.json
@@ -469,7 +469,7 @@
       },
       "mocking_required": true,
       "mock_data": {
-        "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
+        "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_void",
         "return_value": "(False,'Mocked Internal Server Error')"
       },
       "expected_data": {
@@ -547,7 +547,7 @@
       "test_data": {},
       "mocking_required": true,
       "mock_data": {
-        "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
+        "function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_void",
         "return_value": "(False,'Mocked Internal Server Error')"
       },
       "expected_data": {


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin4][Patch] - Test cases failure fix
@ 2021-06-17 10:56  Akshay Joshi <[email protected]>
  parent: Khushboo Vashi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-06-17 10:56 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, the patch applied.

On Thu, Jun 17, 2021 at 3:58 PM Khushboo Vashi <
[email protected]> wrote:

> Hi,
>
> Please find the attached patch to fix the test cases failure due to below
> error on PG 9.6.
>
> psycopg2.errors.ObjectInUse: database "test_db_1658f" is being accessed by other users
> DETAIL:  There is 1 other session using the database.
>
> Thanks,
> Khushboo
>
>
>

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-06-17 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 10:27 [pgAdmin4][Patch] - Test cases failure fix Khushboo Vashi <[email protected]>
2021-06-17 10:56 ` Akshay Joshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox