def test_ErrorColumnsNotUnique(): '''Test the class ErrorColumnsNotUnique (error when their are non unique columns in a database)''' # This file is not created, just a tmp path test_column = "TestColumn" # Test instantiation test_error = NCBImetaErrors.ErrorColumnsNotUnique(test_column) # Test str representation (error message) error_output = str(test_error) error_expect = ("\n\nThe following columns are not unique in the database:" + "\n" + test_column) assert error_output == error_expect
API_KEY = CONFIG_API_KEY if not API_KEY: API_KEY = "" FORCE_PAUSE_SECONDS = CONFIG_FORCE_PAUSE_SECONDS # Config search terms, match table to table name for index, search_term_table in enumerate(CONFIG_SEARCH_TERMS): table_name = list(search_term_table)[0] if table_name == table: break SEARCH_TERM = CONFIG_SEARCH_TERMS[index][table] # Table columns, match table to table name for index, table_column_dict in enumerate(CONFIG_TABLE_COLUMNS): table_name = list(table_column_dict)[0] if table_name == table: break TABLE_COLUMNS = CONFIG_TABLE_COLUMNS[index][table] # Check for duplicate column names # -- Note this is only PER TABLE (Checking for duplicate between table only happens # -- later in the database Join script) table_col_names = [] for element in TABLE_COLUMNS: table_col_names += list(element.keys()) dupl_table_col_names = set( [col for col in table_col_names if table_col_names.count(col) > 1]) if len(dupl_table_col_names) > 0: raise NCBImetaErrors.ErrorColumnsNotUnique(dupl_table_col_names) # Call the main database updating function UpdateDB(table, OUTPUT_DIR, DATABASE, EMAIL, SEARCH_TERM, TABLE_COLUMNS, LOG_PATH, DB_DIR, API_KEY, FORCE_PAUSE_SECONDS)