6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_5908_test.py

52 lines
1.5 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6166
ISSUE: 6166
TITLE: Enhance dynamic libraries loading related error messages
DESCRIPTION:
We intentionally try to load unit from non-existent UDR module with name "udrcpp_foo".
Message 'module not found' issued BEFORE fix - without any detailization.
Current output should contain phrase: 'UDR module not loaded'.
Filtering is used for prevent output of localized message about missed UDR library.
JIRA: CORE-5908
FBTEST: bugs.core_5908
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-10 19:50:31 +01:00
import re
2022-01-26 21:10:46 +01:00
from firebird.qa import *
2021-12-10 19:50:31 +01:00
from firebird.driver import DatabaseError
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
expected_stdout = """
2021-12-10 19:50:31 +01:00
UDR module not loaded
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.4')
2022-01-26 21:10:46 +01:00
def test_1(act: Action, capsys):
2021-12-10 19:50:31 +01:00
udr_ddl = """
create or alter procedure gen_foo2 (
start_n integer not null,
end_n integer not null
) returns( n integer not null )
external name 'udrcpp_foo!gen_rows'
engine udr
2022-01-26 21:10:46 +01:00
"""
2021-12-10 19:50:31 +01:00
pattern = re.compile('\\.*module\\s+not\\s+(found|loaded)\\.*', re.IGNORECASE)
2022-01-26 21:10:46 +01:00
with act.db.connect() as con:
2021-12-10 19:50:31 +01:00
try:
con.execute_immediate(udr_ddl)
con.commit()
except DatabaseError as e:
for line in str(e).splitlines():
if pattern.search(line):
print(line)
# Check
2022-01-26 21:10:46 +01:00
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout