From 192a446131d4f6e28451c6f8b92607a195e888de Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Wed, 1 Jul 2020 15:29:59 +0530 Subject: [PATCH] Fixed API test cases failing due to updating the server manager instance. --- .../schemas/tables/tests/test_table_add.py | 20 ++++++++----- .../schemas/tables/tests/test_table_put.py | 29 ++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_add.py index 4db38710a..1fdf7b6f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_add.py @@ -158,9 +158,19 @@ class TableAddTestCase(BaseTestGenerator): ] def setUp(self): - self.db_name = parent_node_dict["database"][-1]["db_name"] schema_info = parent_node_dict["schema"][-1] self.server_id = schema_info["server_id"] + + if hasattr(self, 'server_min_version'): + server_con = server_utils.connect_server(self, self.server_id) + if not server_con["info"] == "Server connected.": + raise Exception("Could not connect to server to add " + "partitioned table.") + if server_con["data"]["version"] < self.server_min_version: + self.skipTest(self.skip_msg) + + self.db_name = parent_node_dict["database"][-1]["db_name"] + self.db_id = schema_info["db_id"] db_con = database_utils.connect_database(self, utils.SERVER_GROUP, self.server_id, self.db_id) @@ -174,13 +184,7 @@ class TableAddTestCase(BaseTestGenerator): if not schema_response: raise Exception("Could not find the schema to add a table.") - if hasattr(self, 'server_min_version'): - server_con = server_utils.connect_server(self, self.server_id) - if not server_con["info"] == "Server connected.": - raise Exception("Could not connect to server to add " - "partitioned table.") - if server_con["data"]["version"] < self.server_min_version: - self.skipTest(self.skip_msg) + def runTest(self): """ This function will add table under schema node. """ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_put.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_put.py index 6700aff65..0ef9e62e8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_table_put.py @@ -91,20 +91,9 @@ class TableUpdateTestCase(BaseTestGenerator): schema_info = parent_node_dict["schema"][-1] self.server_id = schema_info["server_id"] self.db_id = schema_info["db_id"] - db_con = database_utils.connect_database(self, utils.SERVER_GROUP, - self.server_id, self.db_id) - if not db_con['data']["connected"]: - raise Exception("Could not connect to database to add a table.") self.schema_id = schema_info["schema_id"] self.schema_name = schema_info["schema_name"] - schema_response = schema_utils.verify_schemas(self.server, - self.db_name, - self.schema_name) - if not schema_response: - raise Exception("Could not find the schema to add a table.") - self.table_name = "test_table_put_%s" % (str(uuid.uuid4())[1:8]) - self.is_partition = False if hasattr(self, 'server_min_version'): server_con = server_utils.connect_server(self, self.server_id) if not server_con["info"] == "Server connected.": @@ -114,9 +103,23 @@ class TableUpdateTestCase(BaseTestGenerator): message = "Partitioned table are not supported by " \ "PPAS/PG 10.0 and below." self.skipTest(message) - else: - self.is_partition = True + db_con = database_utils.connect_database(self, utils.SERVER_GROUP, + self.server_id, self.db_id) + if not db_con['data']["connected"]: + raise Exception("Could not connect to database to add a table.") + + schema_response = schema_utils.verify_schemas(self.server, + self.db_name, + self.schema_name) + if not schema_response: + raise Exception("Could not find the schema to add a table.") + + self.table_name = "test_table_put_%s" % (str(uuid.uuid4())[1:8]) + self.is_partition = False + + if hasattr(self, 'server_min_version'): + self.is_partition = True self.table_id = tables_utils.create_table_for_partition( self.server, self.db_name,