2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
|
|
|
ID: issue-2658
|
|
|
|
ISSUE: 2658
|
|
|
|
TITLE: Implement domain check of input parameters of execute block
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-2230
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_2230
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
import pytest
|
2022-01-21 18:49:26 +01:00
|
|
|
from firebird.qa import *
|
2021-11-15 19:01:46 +01:00
|
|
|
from firebird.driver import DatabaseError
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
init_script = """CREATE DOMAIN DOM1 AS INTEGER NOT NULL CHECK (value in (0, 1));
|
2021-04-26 20:07:00 +02:00
|
|
|
"""
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-11-15 19:01:46 +01:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
expected_stdout = """Y
|
2021-04-26 20:07:00 +02:00
|
|
|
-----------
|
|
|
|
1
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-21 18:49:26 +01:00
|
|
|
def test_1(act: Action, capsys):
|
|
|
|
with act.db.connect() as con:
|
2021-11-15 19:01:46 +01:00
|
|
|
c = con.cursor()
|
|
|
|
cmd = c.prepare('execute block (x DOM1 = ?) returns (y integer) as begin y = x; suspend; end')
|
|
|
|
c.execute(cmd, [1])
|
2022-01-21 18:49:26 +01:00
|
|
|
act.print_data(c)
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.stdout = capsys.readouterr().out
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-11-15 19:01:46 +01:00
|
|
|
with pytest.raises(Exception, match='.*validation error for variable X, value "10"'):
|
|
|
|
c.execute(cmd, [10])
|
2022-01-21 18:49:26 +01:00
|
|
|
act.print_data(c)
|