diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_add.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_add.py index e760d93d9..1e84b3533 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_add.py @@ -53,7 +53,7 @@ class FDWDAddTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database and - drop added extension.""" + """This function delete the FDW and disconnect the test database """ + fdw_utils.delete_fdw(self.server, self.db_name, self.data["name"]) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_get.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_get.py index 5a1bd93d4..953ae381d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_get.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_get.py @@ -55,7 +55,7 @@ class FDWDGetTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database and drop added extension - and dependant objects.""" + """This function delete the FDW and disconnect the test database """ + fdw_utils.delete_fdw(self.server, self.db_name, self.fdw_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_put.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_put.py index bc12d3907..cebdc5614 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/test_fdw_put.py @@ -35,7 +35,7 @@ class FDWDPutTestCase(BaseTestGenerator): self.db_id = self.schema_data['db_id'] self.db_name = parent_node_dict["database"][-1]["db_name"] self.schema_name = self.schema_data['schema_name'] - self.fdw_name = "fdw_put_%s".format(str(uuid.uuid4())[1:6]) + self.fdw_name = "fdw_put_{0}".format(str(uuid.uuid4())[1:6]) self.fdw_id = fdw_utils.create_fdw(self.server, self.db_name, self.fdw_name) @@ -65,7 +65,7 @@ class FDWDPutTestCase(BaseTestGenerator): self.assertEquals(put_response.status_code, 200) def tearDown(self): - """This function disconnect the test database and drop added extension - and dependant objects.""" + """This function delete the FDW and disconnect the test database """ + fdw_utils.delete_fdw(self.server, self.db_name, self.fdw_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/utils.py index d8a9e0beb..5808d6784 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/tests/utils.py @@ -108,3 +108,26 @@ def verify_fdw(server, db_name, fdw_name): return fdw except Exception: traceback.print_exc(file=sys.stderr) + + +def delete_fdw(server, db_name, fdw_name): + """ + This function delete FDW. + :param server: server details + :type server: dict + :param db_name: database name + :type db_name: str + :param fdw_name: fdw name to be deleted + :type fdw_name: str + :return: None + """ + connection = get_db_connection(db_name, + server['username'], + server['db_password'], + server['host'], + server['port'], + server['sslmode']) + pg_cursor = connection.cursor() + pg_cursor.execute("DROP FOREIGN DATA WRAPPER %s" % fdw_name) + connection.commit() + connection.close() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_add.py index 55a0be8cf..c71c02d1b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_add.py @@ -16,6 +16,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas. \ fts_parser.tests import utils as fts_parser_utils from pgadmin.browser.server_groups.servers.databases.schemas.tests import \ utils as schema_utils +from pgadmin.browser.server_groups.servers.databases.schemas \ + .fts_configurations.tests import utils as fts_config_utils from pgadmin.browser.server_groups.servers.databases.tests import \ utils as database_utils from pgadmin.utils.route import BaseTestGenerator @@ -42,11 +44,8 @@ class FTSConfiguraionAddTestCase(BaseTestGenerator): self.db_id = schema_data['db_id'] self.db_name = parent_node_dict["database"][-1]["db_name"] self.fts_parser_name = "fts_parser_%s" % str(uuid.uuid4())[1:4] - - self.fts_parser_id = fts_parser_utils.create_fts_parser(self.server, - self.db_name, - self.schema_name, - self.fts_parser_name) + self.fts_parser_id = fts_parser_utils.create_fts_parser( + self.server, self.db_name, self.schema_name, self.fts_parser_name) def runTest(self): """ This function will add new FTS configuration under test schema. """ @@ -65,9 +64,10 @@ class FTSConfiguraionAddTestCase(BaseTestGenerator): if not schema_response: raise Exception("Could not find the schema.") + self.fts_conf_name = "fts_conf_%s" % str(uuid.uuid4())[1:4] data = \ { - "name": "fts_conf_%s" % str(uuid.uuid4())[1:4], + "name": self.fts_conf_name, "owner": self.server["username"], "prsname": "%s.%s" % (self.schema_name, self.fts_parser_name), "schema": self.schema_id, @@ -84,7 +84,10 @@ class FTSConfiguraionAddTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_config and disconnect the test + database.""" + fts_config_utils.delete_fts_configurations(self.server, self.db_name, + self.schema_name, + self.fts_conf_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_get.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_get.py index b148db380..8b2990341 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_get.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_get.py @@ -15,6 +15,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tests import \ utils as schema_utils from pgadmin.browser.server_groups.servers.databases.tests import \ utils as database_utils +from pgadmin.browser.server_groups.servers.databases.schemas \ + .fts_configurations.tests import utils as fts_config_utils from pgadmin.utils.route import BaseTestGenerator from regression import parent_node_dict from regression.python_test_utils import test_utils as utils @@ -45,7 +47,8 @@ class FTSConfGetTestCase(BaseTestGenerator): self.server, self.db_name, self.schema_name, self.fts_conf_name) def runTest(self): - """ This function will fetch new FTS configuration under test schema. """ + """ This function will fetch new FTS configuration under test schema. + """ db_con = database_utils.connect_database(self, utils.SERVER_GROUP, @@ -61,17 +64,21 @@ class FTSConfGetTestCase(BaseTestGenerator): if not schema_response: raise Exception("Could not find the schema.") - get_response = self.tester.get(self.url + str(utils.SERVER_GROUP) + '/' + - str(self.server_id) + '/' + - str(self.db_id) + '/' + - str(self.schema_id) + '/' + - str(self.fts_conf_id), - content_type='html/json') + get_response = self.tester.get( + self.url + str(utils.SERVER_GROUP) + '/' + + str(self.server_id) + '/' + + str(self.db_id) + '/' + + str(self.schema_id) + '/' + + str(self.fts_conf_id), + content_type='html/json') self.assertEquals(get_response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_config and disconnect the test + database.""" + fts_config_utils.delete_fts_configurations(self.server, self.db_name, + self.schema_name, + self.fts_conf_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_put.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_put.py index 1c66543fa..80917ae6b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/test_fts_configuration_put.py @@ -16,6 +16,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tests import \ utils as schema_utils from pgadmin.browser.server_groups.servers.databases.tests import \ utils as database_utils +from pgadmin.browser.server_groups.servers.databases.schemas \ + .fts_configurations.tests import utils as fts_config_utils from pgadmin.utils.route import BaseTestGenerator from regression import parent_node_dict from regression.python_test_utils import test_utils as utils @@ -87,7 +89,10 @@ class FTSConfPutTestCase(BaseTestGenerator): self.assertEquals(put_response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_config and disconnect the test + database.""" + fts_config_utils.delete_fts_configurations(self.server, self.db_name, + self.schema_name, + self.fts_conf_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/utils.py index 4e4fd0039..34b6914a5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/tests/utils.py @@ -83,3 +83,29 @@ def verify_fts_configuration(server, db_name, fts_conf_name): return fts_conf except Exception: traceback.print_exc(file=sys.stderr) + + +def delete_fts_configurations(server, db_name, schema_name, fts_conf_name): + """ + This function delete FTS configuration. + :param server: server details + :type server: dict + :param db_name: database name + :type db_name: str + :param fts_conf_name: FTS configuration name to be added + :type fts_conf_name: str + :param schema_name: schema name + :type schema_name: str + :return: None + """ + connection = get_db_connection(db_name, + server['username'], + server['db_password'], + server['host'], + server['port'], + server['sslmode']) + pg_cursor = connection.cursor() + pg_cursor.execute("DROP TEXT SEARCH CONFIGURATION %s.%s" % (schema_name, + fts_conf_name)) + connection.commit() + connection.close() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_add.py index bb484ba8d..a4302b374 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_add.py @@ -16,6 +16,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.tests import \ utils as schema_utils from pgadmin.browser.server_groups.servers.databases.tests import \ utils as database_utils +from pgadmin.browser.server_groups.servers.databases.schemas \ + .fts_dictionaries.tests import utils as fts_dict_utils from pgadmin.utils.route import BaseTestGenerator from regression import parent_node_dict from regression.python_test_utils import test_utils as utils @@ -52,10 +54,10 @@ class FtsDictionaryAddTestCase(BaseTestGenerator): self.schema_name) if not schema_response: raise Exception("Could not find the schema.") - + self.fts_dict_name = "fts_dict_%s" % str(uuid.uuid4())[1:4] data = \ { - "name": "fts_dict_%s" % str(uuid.uuid4())[1:4], + "name": self.fts_dict_name, "options": [ { "value": "synonym_sample", @@ -77,7 +79,10 @@ class FtsDictionaryAddTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts dictionaries and disconnect the test + database.""" + fts_dict_utils.delete_fts_dictionaries(self.server, self.db_name, + self.schema_name, + self.fts_dict_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_get.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_get.py index 966ece421..ff52e3faa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_get.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_get.py @@ -47,7 +47,8 @@ class FtsDictionaryGetTestCase(BaseTestGenerator): self.fts_dict_name) def runTest(self): - """ This function will fetch new FTS dictionaries under test schema. """ + """ This function will fetch new FTS dictionaries under test schema. + """ db_con = database_utils.connect_database(self, utils.SERVER_GROUP, self.server_id, @@ -72,7 +73,10 @@ class FtsDictionaryGetTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts dictionaries and disconnect the test + database.""" + fts_dict_utils.delete_fts_dictionaries(self.server, self.db_name, + self.schema_name, + self.fts_dict_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_put.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_put.py index ee043206a..700426156 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/test_fts_dictionaries_put.py @@ -48,7 +48,8 @@ class FtsDictionaryPutTestCase(BaseTestGenerator): self.fts_dict_name) def runTest(self): - """ This function will update FTS dictionary present under test schema. """ + """ This function will update FTS dictionary present under test schema. + """ db_con = database_utils.connect_database(self, utils.SERVER_GROUP, @@ -89,7 +90,10 @@ class FtsDictionaryPutTestCase(BaseTestGenerator): self.assertEquals(put_response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts dictionaries and disconnect the test + database.""" + fts_dict_utils.delete_fts_dictionaries(self.server, self.db_name, + self.schema_name, + self.fts_dict_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/utils.py index 0fcfff839..d31dcffff 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/tests/utils.py @@ -82,3 +82,29 @@ def verify_fts_dict(server, db_name, fts_dict_name): return fts_dict except Exception: traceback.print_exc(file=sys.stderr) + + +def delete_fts_dictionaries(server, db_name, schema_name, fts_dict_name): + """ + This function delete FTS dictionaries. + :param server: server details + :type server: dict + :param db_name: database name + :type db_name: str + :param fts_dict_name: FTS dict name to be added + :type fts_dict_name: str + :param schema_name: schema name + :type schema_name: str + :return: None + """ + connection = get_db_connection(db_name, + server['username'], + server['db_password'], + server['host'], + server['port'], + server['sslmode']) + pg_cursor = connection.cursor() + pg_cursor.execute("DROP TEXT SEARCH DICTIONARY %s.%s" % (schema_name, + fts_dict_name)) + connection.commit() + connection.close() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_add.py index 3ae500b26..4f9e7e373 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_add.py @@ -19,6 +19,7 @@ from pgadmin.browser.server_groups.servers.databases.tests import \ from pgadmin.utils.route import BaseTestGenerator from regression import parent_node_dict from regression.python_test_utils import test_utils as utils +from . import utils as fts_parser_utils class FtsParserAddTestCase(BaseTestGenerator): @@ -52,9 +53,10 @@ class FtsParserAddTestCase(BaseTestGenerator): if not schema_response: raise Exception("Could not find the schema.") + self.fts_parser_name = "fts_parser_%s" % str(uuid.uuid4())[1:4] self.data = \ { - "name": "fts_parser_%s" % str(uuid.uuid4())[1:4], + "name": self.fts_parser_name, "schema": self.schema_id, "prsend": "prsd_end", "prsheadline": "prsd_headline", @@ -73,7 +75,10 @@ class FtsParserAddTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_parser and disconnect the test + database.""" + fts_parser_utils.delete_fts_parser(self.server, self.db_name, + self.schema_name, + self.fts_parser_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_get.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_get.py index 07c8eea93..adde37138 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_get.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_get.py @@ -71,7 +71,10 @@ class FtsParserGetTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_parser and disconnect the test + database.""" + fts_parser_utils.delete_fts_parser(self.server, self.db_name, + self.schema_name, + self.fts_parser_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_put.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_put.py index 7eb17b2e8..6952fd494 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/test_fts_parser_put.py @@ -88,7 +88,10 @@ class FtsParserPutTestCase(BaseTestGenerator): self.assertEquals(put_response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_parser and disconnect the test + database.""" + fts_parser_utils.delete_fts_parser(self.server, self.db_name, + self.schema_name, + self.fts_parser_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/utils.py index 72ee282c2..c156651e2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/tests/utils.py @@ -86,3 +86,29 @@ def verify_fts_parser(server, db_name, fts_parser_name): return fts_parser except Exception: traceback.print_exc(file=sys.stderr) + + +def delete_fts_parser(server, db_name, schema_name, fts_parser_name): + """ + This function delete FTS parsers. + :param server: server details + :type server: dict + :param db_name: database name + :type db_name: str + :param fts_parser_name: FTS parser name to be added + :type fts_parser_name: str + :param schema_name: schema name + :type schema_name: str + :return: None + """ + connection = get_db_connection(db_name, + server['username'], + server['db_password'], + server['host'], + server['port'], + server['sslmode']) + pg_cursor = connection.cursor() + pg_cursor.execute("DROP TEXT SEARCH PARSER %s.%s" % ( + schema_name, fts_parser_name)) + connection.commit() + connection.close() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_add.py index 8683ff258..7ee909566 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_add.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_add.py @@ -19,6 +19,7 @@ from pgadmin.browser.server_groups.servers.databases.tests import \ from pgadmin.utils.route import BaseTestGenerator from regression import parent_node_dict from regression.python_test_utils import test_utils as utils +from . import utils as fts_temp_utils class FtsTemplateAddTestCase(BaseTestGenerator): @@ -26,7 +27,8 @@ class FtsTemplateAddTestCase(BaseTestGenerator): scenarios = [ # Fetching default URL for FTS template node. - ('Fetch FTS templates Node URL', dict(url='/browser/fts_template/obj/')) + ( + 'Fetch FTS templates Node URL', dict(url='/browser/fts_template/obj/')) ] def runTest(self): @@ -54,9 +56,10 @@ class FtsTemplateAddTestCase(BaseTestGenerator): if not schema_response: raise Exception("Could not find the schema.") + self.fts_template_name = "fts_temp_%s" % str(uuid.uuid4())[1:4] self.data = \ { - "name": "fts_temp_%s" % str(uuid.uuid4())[1:4], + "name": self.fts_template_name, "schema": self.schema_id, "tmplinit": "dispell_init", "tmpllexize": "dispell_lexize" @@ -72,7 +75,10 @@ class FtsTemplateAddTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_template and disconnect the test + database.""" + fts_temp_utils.delete_fts_template(self.server, self.db_name, + self.schema_name, + self.fts_template_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_get.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_get.py index cff9696a4..1c068e154 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_get.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_get.py @@ -71,7 +71,10 @@ class FtsTemplateGetTestCase(BaseTestGenerator): self.assertEquals(response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_template and disconnect the test + database.""" + fts_temp_utils.delete_fts_template(self.server, self.db_name, + self.schema_name, + self.fts_temp_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_put.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_put.py index 3d314f575..4fa0db04c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_put.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/test_fts_templates_put.py @@ -88,7 +88,10 @@ class FtsTemplatePutTestCase(BaseTestGenerator): self.assertEquals(put_response.status_code, 200) def tearDown(self): - """This function disconnect the test database.""" - + """This function delete the fts_template and disconnect the test + database.""" + fts_temp_utils.delete_fts_template(self.server, self.db_name, + self.schema_name, + self.fts_temp_name) database_utils.disconnect_database(self, self.server_id, self.db_id) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/utils.py index 7fd0873e6..448a45da4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/tests/utils.py @@ -82,3 +82,29 @@ def verify_fts_template(server, db_name, fts_temp_name): return fts_template except Exception: traceback.print_exc(file=sys.stderr) + + +def delete_fts_template(server, db_name, schema_name, fts_template_name): + """ + This function delete FTS parsers. + :param server: server details + :type server: dict + :param db_name: database name + :type db_name: str + :param fts_template_name: FTS template name to be added + :type fts_template_name: str + :param schema_name: schema name + :type schema_name: str + :return: None + """ + connection = get_db_connection(db_name, + server['username'], + server['db_password'], + server['host'], + server['port'], + server['sslmode']) + pg_cursor = connection.cursor() + pg_cursor.execute("DROP TEXT SEARCH TEMPLATE %s.%s" % ( + schema_name, fts_template_name)) + connection.commit() + connection.close()