public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch] - Test cases failure fix
Date: Thu, 17 Jun 2021 15:57:44 +0530
Message-ID: <CAFOhELdW4vPV_u_DQAcbcNHzLujYdq5P0O46+Z9mA+=ekiYRTg@mail.gmail.com> (raw)
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": {
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin4][Patch] - Test cases failure fix
In-Reply-To: <CAFOhELdW4vPV_u_DQAcbcNHzLujYdq5P0O46+Z9mA+=ekiYRTg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox