def runTest(self): """This function will delete check constraint to table.""" if self.is_positive_test: if self.is_list: response = check_constraint_utils.api_delete(self, '') else: response = check_constraint_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = check_constraint_utils.verify_check_constraint( self.server, self.db_name, self.check_constraint_name) self.assertIsNone(cross_check_res, "Deleted constraint still present") 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_delete(self) elif 'check_constraint_id' in self.data: self.check_constraint_id = self.data["check_constraint_id"] response = check_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 fetch the view/mview 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) # Check definition data test_result_data = self.expected_data["test_result_data"] if bool(test_result_data): response_data = json.loads(response.data.decode('utf-8')) if self.server['type'] == 'pg': self.assertIn(test_result_data["pg_definition"], response_data['definition']) else: self.assertIn(test_result_data["definition"], response_data['definition']) 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 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 delete added table under schema node.""" if self.is_positive_test: if self.is_list: response = tables_utils.api_get(self, "") else: response = tables_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 = tables_utils.api_get(self, "") else: response = tables_utils.api_get(self) else: if 'table_id' in self.data: self.table_id = self.data['table_id'] response = tables_utils.api_get(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will update foreign table under test database.""" 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.") ft_response = ft_utils.verify_foreign_table(self.server, self.db_name, self.fsrv_name) if not ft_response: raise Exception("Could not find Foreign Table.") self.data['id'] = self.ft_id if self.is_positive_test: response = ft_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 = ft_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 added table under schema node.""" url_encode_data = None if hasattr(self, "url_encoded_data"): if "tid" in self.data: self.data["tid"] = self.table_id elif "tname" in self.data: self.data["tname"] = self.table_name url_encode_data = self.data if self.is_positive_test: response = tables_utils.api_get_pre_table_creation_params( self, url_encode_data) # 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_get_pre_table_creation_params( self, url_encode_data) else: if 'table_id' in self.data: self.table_id = self.data['table_id'] response = tables_utils.api_get_pre_table_creation_params( self, url_encode_data) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will add check constraint to table.""" if "name" in self.data: check_constraint_name = \ self.data["name"] + (str(uuid.uuid4())[1:8]) self.data["name"] = check_constraint_name if self.is_positive_test: response = check_constraint_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = check_constraint_utils. \ verify_check_constraint(self.server, self.db_name, self.data["name"]) self.assertIsNotNone( cross_check_res, "Could not find the newly" " created check constraint.") 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_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 = check_constraint_utils.api_create(self) # Assert response utils.assert_status_code(self, response)
def runTest(self): """This function will get pgAgent job nodes""" if self.is_positive_test: if self.is_list: response = pgagent_utils.api_get(self, '') else: response = pgagent_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 = pgagent_utils.api_get(self) elif 'job_id' in self.data: # Non-existing job id existing_job_id = self.job_id self.job_id = self.data["job_id"] response = pgagent_utils.api_get(self) self.job_id = existing_job_id # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): self.pgagent_step_name = "test_step_add%s" % str(uuid.uuid4())[1:8] self.data["jstjobid"] = self.job_id self.data["jstname"] = self.pgagent_step_name if self.is_positive_test: response = steps_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend response_data = json.loads(response.data) self.step_id = response_data['node']['_id'] is_present = pgagent_utils.verify_pgagent_step(self) self.assertTrue(is_present, "pgAgent step was not created successfully.") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = steps_utils.api_create(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will delete the view/mview under schema node.""" if self.is_positive_test: if self.is_list: response = views_utils.api_delete(self, '') else: response = views_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) # Verify in backend view_response = views_utils.verify_view(self.server, self.db_name, self.view_name) self.assertIsNone(view_response, "Deleted view still present") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = views_utils.api_delete(self) elif 'view_id' in self.data: self.view_id = self.data["view_id"] response = views_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 exclusion constraint to existing table.""" if "name" in self.data: constraint_name = self.data["name"] + (str(uuid.uuid4())[1:8]) self.data["name"] = constraint_name elif self.db_version < 110000: constraint_name = self.table_name + '_' + \ self.data["columns"][0]['column'] + '_excl' else: constraint_name = self.table_name + '_' + \ self.data["columns"][0]['column'] + '_name_excl' if self.is_positive_test: response = exclusion_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend cross_check_res = exclusion_utils.verify_exclusion_constraint( self.server, self.db_name, constraint_name) self.assertIsNotNone( cross_check_res, "Could not find the newly created exclusion " "constraint.") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = exclusion_utils.api_create(self) else: response = exclusion_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 column under table node.""" if "name" in self.data: self.data["name"] = self.data["name"] + (str(uuid.uuid4())[1:8]) if self.is_positive_test: response = columns_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend self.assertIsNotNone( columns_utils.verify_column(self.server, self.db_name, self.data["name"]), "Column not found") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = columns_utils.api_create(self) else: if 'table_id' in self.data: self.table_id = self.data['table_id'] response = columns_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 the column dependencies/dependents under table node.""" if self.is_positive_test: if self.is_dependent: self.url = self.url + 'dependent/' response = columns_utils.api_get(self) else: self.url = self.url + 'dependency/' response = columns_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if self.is_dependent: self.url = self.url + 'dependent/' else: self.url = self.url + 'dependency/' if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=eval(self.mock_data["return_value"])): response = columns_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 foreign key attached to table column.""" if self.is_positive_test: if self.is_list: self.data['ids'] = [self.foreign_key_id] response = fk_utils.api_delete(self, '') else: response = fk_utils.api_delete(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) self.assertIsNone(cross_check_res, "Deleted foreign key still present") else: if self.mocking_required: with patch(self.mock_data["function_name"], side_effect=[eval(self.mock_data["return_value"])]): response = fk_utils.api_delete(self) elif 'foreign_key_id' in self.data: self.foreign_key_id = self.data["foreign_key_id"] response = fk_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 column under table node.""" if self.is_positive_test: if self.is_list: response = columns_utils.api_get(self, "") else: response = columns_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 = columns_utils.api_get(self, "") else: response = columns_utils.api_get(self) else: if 'column_id' in self.data: self.column_id = self.data['column_id'] response = columns_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 index constraint(primary key or unique key) to table column.""" # Create using index if "index" in self.data: index_name = self.data["index"] + (str(uuid.uuid4())[1:8]) self.data["index"] = index_name self.index_id = index_constraint_utils.create_unique_index( self.server, self.db_name, self.schema_name, self.table_name, index_name, "name") # Constraint name if "constraint_name" in self.data: constraint_name = self.data["constraint_name"] + ( str(uuid.uuid4())[1:8]) self.data["name"] = constraint_name else: if "index" in self.data: if "primary_key" in self.url: constraint_name = index_name else: constraint_name = self.table_name + '_id_key' else: if "primary_key" in self.url: constraint_name = self.table_name + '_pkey' elif "columns" in self.data: constraint_name = self.table_name + '_' + \ self.data["columns"][0]["column"] + '_key' if self.is_positive_test: response = index_constraint_utils.api_create(self) # Assert response utils.assert_status_code(self, response) # Verify in backend self.assertIsNotNone(index_constraint_utils. verify_index_constraint(self.server, self.db_name, constraint_name), "Could not find constraint created.") 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_create(self) else: response = index_constraint_utils.api_create(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: response = tables_utils.api_delete(self) # Assert response utils.assert_status_code(self, response) 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 get pgAgent job step stats""" if self.is_positive_test: 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) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will validate check constraint to table.""" if self.is_positive_test: 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) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will update pgAgent schedule""" # Check and Delete entry for pga_exception table for the specified # date and time as no primary key is defined for pga_exception table # and there is a unique constraint for date and time. So when we run # the test cases multiple time then it will fail with unique # constraint error. if 'jscexceptions' in self.data: exception_data = self.data['jscexceptions'] if 'added' in exception_data: pgagent_utils.delete_pgagent_exception( self, self.data['jscexceptions']['added'][0]['jexdate'], self.data['jscexceptions']['added'][0]['jextime']) elif 'changed' in exception_data: date = self.data['jscexceptions']['changed'][0]['jexdate'] time = self.data['jscexceptions']['changed'][0]['jextime'] self.excp_id = pgagent_utils.create_pgagent_exception( self, self.schedule_id, date, time) self.data['jscexceptions']['changed'][0]['jexid'] = \ self.excp_id elif 'deleted' in exception_data: date = self.data['jscexceptions']['deleted'][0]['jexdate'] time = self.data['jscexceptions']['deleted'][0]['jextime'] self.excp_id = pgagent_utils.create_pgagent_exception( self, self.schedule_id, date, time) self.data['jscexceptions']['deleted'][0]['jexid'] = \ self.excp_id self.data['jscid'] = str(self.schedule_id) if self.is_positive_test: response = schedules_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 = pgagent_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will update index constraint(primary key or unique key) of table column.""" self.data["oid"] = self.index_constraint_id if self.is_positive_test: response = index_constraint_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 = index_constraint_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will update an existing exclusion constraint""" self.data["oid"] = self.exclusion_constraint_id if self.is_positive_test: response = exclusion_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 = exclusion_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will update foreign key attached to table column.""" self.data["oid"] = self.foreign_key_id if self.is_positive_test: response = fk_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 = fk_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch the column node/nodes under table node.""" if self.is_positive_test: if self.is_list: response = columns_utils.api_get(self, "") else: response = columns_utils.api_get(self) # Assert response utils.assert_status_code(self, response) else: if 'column_id' in self.data: self.column_id = self.data['column_id'] response = columns_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 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 function will update the column under table node.""" self.data.update({ 'attnum': self.column_id, 'name': self.column_name, }) if self.is_positive_test: response = columns_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 = columns_utils.api_put(self) # Assert response utils.assert_status_code(self, response) utils.assert_error_message(self, response)
def runTest(self): """This function will fetch sql for check constraint to table.""" if self.is_positive_test: 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) elif '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 fetch foreign key nodes attached to table column. """ if self.is_positive_test: if self.is_list: response = fk_utils.api_get(self, '') else: response = fk_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 = fk_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_list: response = ft_utils.api_get(self, '') else: 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 the view/mview sql under schema node.""" if self.is_positive_test: 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 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)