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

Added/Updated tests\functional\trigger\table\test_alter_07.py: changed substitutions so that only relevant lines from full error text will be filtered and checked.

This commit is contained in:
pavel-zotov 2023-05-11 11:15:19 +03:00
parent 988af895a1
commit 96bb653557

View File

@ -2,8 +2,8 @@
"""
ID: trigger.table.alter-07
TITLE: ALTER TRIGGER - AFTER INSERT
DESCRIPTION:
TITLE: ALTER TRIGGER: attempt to use "new" in AFTER INSERT
DESCRIPTION: an attempt to change the trigger event to 'AFTER' should be rejected if trigger uses 'new' context variable.
FBTEST: functional.trigger.table.alter_07
"""
@ -11,71 +11,54 @@ import pytest
from firebird.qa import *
init_script = """
CREATE TABLE test( id INTEGER NOT NULL CONSTRAINT unq UNIQUE, text VARCHAR(32));
SET TERM ^;
CREATE TRIGGER tg FOR test BEFORE UPDATE
AS
BEGIN
new.id=1;
END ^
SET TERM ;^
create table test( id int primary key);
set term ^;
create trigger trg_test_bu for test before update as
begin
new.id=1;
end ^
set term ;^
commit;
"""
db = db_factory(init=init_script)
test_script = """
ALTER TRIGGER tg AFTER INSERT;
SHOW TRIGGER tg;
ALTER TRIGGER trg_test_bu AFTER INSERT;
"""
act = isql_act('db', test_script, substitutions=[('\\+.*',''),('\\=.*',''),('Trigger text.*',''), ('-attempted', 'attempted'), ('-ID',''), ('Error while parsing trigger TG\'s BLR', '')])
# FB 3.x:
# Statement failed, SQLSTATE = 42000
# attempted update of read-only column
# FB 4.x and 5.x:
# Statement failed, SQLSTATE = 42000
# attempted update of read-only column TEST.ID
substitutions = [
('^((?!SQLSTATE|column).)*$', '')
,('-attempted', 'attempted')
]
act = isql_act('db', test_script, substitutions = substitutions)
expected_stdout_fb3 = """
Triggers on Table TEST:
=============================================================================
TG, Sequence: 0, Type: BEFORE UPDATE, Active
Trigger text:
=============================================================================
AS
BEGIN
new.id=1;
END
=============================================================================
"""
expected_stderr_fb3 = """
Statement failed, SQLSTATE = 2F000
Error while parsing trigger TG's BLR
-attempted update of read-only column
-ID
"""
expected_stdout_fb4 = """
Triggers on Table TEST:
TG, Sequence: 0, Type: BEFORE UPDATE, Active
AS
BEGIN
new.id=1;
END
Statement failed, SQLSTATE = 42000
attempted update of read-only column
"""
expected_stderr_fb4 = """
Statement failed, SQLSTATE
Error while parsing trigger TG's BLR
-attempted update of read-only column TEST.ID
Statement failed, SQLSTATE = 42000
attempted update of read-only column TEST.ID
"""
@pytest.mark.version('>=3.0')
def test_1(act: Action):
if act.is_version('>=4.0'):
act.expected_stderr = expected_stderr_fb4
act.expected_stdout = expected_stdout_fb4
else:
act.expected_stderr = expected_stderr_fb3
act.expected_stdout = expected_stdout_fb3
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
assert act.clean_stderr == act.clean_expected_stderr
assert act.clean_stderr == act.clean_expected_stderr