def test_ErrorAnnotFileNotExists(tmpdir): '''Test the class ErrorAnnotFileNotExists (error when an annotation file doesn't exist)''' # This file is not created, just a tmp path tmpfile = os.path.join(tmpdir.strpath, "tmpfile") # Test instantiation test_error = NCBImetaErrors.ErrorAnnotFileNotExists(tmpfile) # Test str representation (error message) error_output = str(test_error) error_expect = ("\n\nFile does not exist." + "\n" + "User entered: --annotfile " + tmpfile) assert error_output == error_expect
db_value_sep = ";" #-----------------------------------------------------------------------# # Argument Checking # #-----------------------------------------------------------------------# #---------------------------Check Database------------------------------# if os.path.exists(db_name): conn = sqlite3.connect(db_name) print('\nOpening database: ' + db_name, flush=True) else: raise NCBImetaErrors.ErrorDBNotExists(db_name) if not os.path.exists(annot_file_name): raise NCBImetaErrors.ErrorAnnotFileNotExists(annot_file_name) # no errors were raised, safe to connect to db cur = conn.cursor() #---------------------------Check Table---------------------------------# # Check table name table_name = db_table table_name_sanitize = NCBImetaUtilities.sql_sanitize(table_name) if table_name != table_name_sanitize: raise NCBImetaErrors.ErrorSQLNameSanitize(table_name, table_name_sanitize) # Check table exists if not NCBImetaUtilities.table_exists(cur, db_table): raise NCBImetaErrors.ErrorTableNotInDB(db_table)