def runTest(self): """This function will fetch foreign table under test database.""" # Create db connection db_con = database_utils.connect_database(self, utils.SERVER_GROUP, self.server_id, self.db_id) if not db_con["info"] == "Database connected.": raise Exception("Could not connect to database.") fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name, self.fsrv_name) if not fsrv_response: raise Exception("Could not find Foreign Server.") if self.is_positive_test: response = ft_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): if self.is_list: response = ft_utils.api_get(self, '') else: response = ft_utils.api_get(self) elif 'ft_id' in self.data: # Non-existing ft_id id self.ft_id = self.data["ft_id"] response = ft_utils.api_get(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch check constraint to table.""" if self.is_positive_test: if self.is_list: response = check_constraint_utils.api_get(self, '') else: response = check_constraint_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = check_constraint_utils.api_get(self) else: if 'check_constraint_id' in self.data: # Non-existing constraint id self.check_constraint_id = self.data["check_constraint_id"] response = check_constraint_utils.api_get(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will delete added table under schema node.""" if self.is_positive_test: if self.is_list: self.data["ids"] = [self.table_id, self.table_id_1] response = tables_utils.api_delete(self, "") else: response = tables_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = tables_utils.api_delete(self) else: if 'table_id' in self.data: self.table_id = self.data['table_id'] response = tables_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch the view/mview nodes under schema node.""" if self.is_positive_test: if self.is_list: response = views_utils.api_get(self, '') else: response = views_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = views_utils.api_get(self) elif 'view_id' in self.data: # Non-existing view/mview id self.view_id = self.data["view_id"] response = views_utils.api_get(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will add foreign key table column.""" # FK name if "name" in self.data: fk_name = self.data["name"] + (str(uuid.uuid4())[1:8]) self.data["name"] = fk_name else: fk_name = self.local_table_name + '_' + \ self.data["columns"][0]["local_column"] + '_fkey' # FK table name if "columns" in self.data: self.data["columns"][0]["references"] = self.foreign_table_id if self.is_positive_test: response = fk_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = fk_utils.verify_foreignkey( self.server, self.db_name, self.local_table_name, fk_name) self.assertIsNotNone(cross_check_res, "Could not find foreign key.") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = fk_utils.api_create(self) else: response = fk_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch pgAgent job nodes""" if self.is_positive_test: if self.is_list: self.data['ids'] = [self.step_id, self.step_id_2] response = steps_utils.api_get(self, '') else: response = steps_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = steps_utils.api_get(self) else: if "step_id" in self.data: self.step_id = self.data["step_id"] response = steps_utils.api_get(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch foreign table under test database.""" # Create db connection db_con = database_utils.connect_database(self, utils.SERVER_GROUP, self.server_id, self.db_id) if not db_con["info"] == "Database connected.": raise Exception("Could not connect to database.") fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name, self.fsrv_name) if not fsrv_response: raise Exception("Could not find Foreign Server.") if self.is_positive_test: if self.is_dependent: self.url = self.url + 'dependent/' response = ft_utils.api_get(self) else: self.url = self.url + 'dependency/' response = ft_utils.api_get(self) utils.assert_status_code(self, response)
def runTest(self): """This function will fetch added table under schema node.""" self.data["id"] = self.table_id if self.is_partition: tables_utils.set_partition_data( self.server, self.db_name, self.schema_name, self.table_name, self.inventory_data["partition_type"], self.data, self.inventory_data["mode"]) if self.is_positive_test: response = tables_utils.api_put(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = tables_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will delete index constraint(primary key or unique key) of table column.""" if self.is_positive_test: if self.is_list: self.data['ids'] = [self.index_constraint_id] response = index_constraint_utils.api_delete(self, '') else: response = index_constraint_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = index_constraint_utils.api_delete(self) elif 'index_constraint_id' in self.data: self.index_constraint_id = self.data["index_constraint_id"] response = index_constraint_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will add foreign table under test database.""" # Create db connection db_con = database_utils.connect_database(self, utils.SERVER_GROUP, self.server_id, self.db_id) if not db_con["info"] == "Database connected.": raise Exception("Could not connect to database.") fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name, self.fsrv_name) if not fsrv_response: raise Exception("Could not find Foreign Server.") if self.is_positive_test: response = ft_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = ft_utils.verify_foreign_table(self.server, self.db_name, self.fsrv_name) self.assertIsNotNone(cross_check_res, "Could not find the newly" " created foreign table.") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = ft_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response) else: del self.data['ftsrvname'] response = ft_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will add view under schema node.""" db_user = self.server["username"] self.data["schema"] = self.schema_id self.data["owner"] = db_user if "name" in self.data: view_name = \ self.data["name"] + (str(uuid.uuid4())[1:8]) self.data["name"] = view_name if self.is_positive_test: response = views_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = views_utils.verify_view(self.server, self.db_name, self.data["name"]) self.assertIsNotNone( cross_check_res, "Could not find the newly" " created check view.") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = views_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response) else: if 'table_id' in self.data: self.table_id = self.data['table_id'] response = views_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This class will check materialized view refresh functionality""" mview_response = views_utils.verify_view(self.server, self.db_name, self.m_view_name) if not mview_response: raise Exception("Could not find the mview to update.") if self.is_put_request: # Check utility url_from_test_data = self.url self.url = 'browser/mview/check_utility_exists/' response = views_utils.api_get(self) if response.json['success'] == 0: self.skipTest("Couldn't check materialized view refresh " "functionality because utility/binary does " "not exists.") # reset self.url value self.url = url_from_test_data if self.is_positive_test: response = views_utils.api_put(self) # Assert response utils.assert_status_code(self, response) self.assertTrue('job_id' in response.json['data']) else: if 'm_view_id' in self.data: self.view_id = self.data['m_view_id'] response = views_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response) else: # only check utility response = views_utils.api_get(self) # Assert response utils.assert_status_code(self, response)
def runTest(self): """ This function will add table under schema node. """ if "table_name" in self.data: self.table_name = self.data["table_name"] else: self.table_name = "test_table_add_%s" % (str(uuid.uuid4())[1:8]) db_user = self.server["username"] # Get the common data self.data.update(tables_utils.get_table_common_data()) if self.server_information and \ 'server_version' in self.server_information and \ self.server_information['server_version'] >= 120000: self.data['spcname'] = None self.data.update({ "name": self.table_name, "relowner": db_user, "schema": self.schema_name, "relacl": [{ "grantee": db_user, "grantor": db_user, "privileges": [{ "privilege_type": "a", "privilege": True, "with_grant": True }, { "privilege_type": "r", "privilege": True, "with_grant": False }, { "privilege_type": "w", "privilege": True, "with_grant": False }] }] }) # Add table if self.is_positive_test: response = tables_utils.api_create(self) # Assert response utils.assert_status_code(self, response) else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = tables_utils.api_create(self) else: if self.table_name == "": del self.data["name"] response = tables_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)