2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-19 17:54:56 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-632
|
|
|
|
ISSUE: 632
|
|
|
|
TITLE: Provide mechanism to get engine version without needing to call API function
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-1018
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2022-01-19 17:54:56 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
# version: 3.0
|
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
set list on;
|
|
|
|
-- Engine version could contain more than one digit in any section or more sections.
|
|
|
|
-- Changed pattern for matching such cases of engine version as:
|
|
|
|
-- '3.2.23' or '3.3.2.1.0.1.2.3.4.5.7' etc
|
|
|
|
select iif( t.ev similar to '[0-9]+.[0-9]+.[0-9]+((.?[0-9]+)*)', substring(ev from 1 for 3), null) as version
|
|
|
|
from (
|
|
|
|
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') ev
|
|
|
|
from rdb$database
|
|
|
|
)t;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
act_1 = isql_act('db', test_script_1)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|
|
|
VERSION 3.0
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0,<4.0')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_1(act_1: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
act_1.expected_stdout = expected_stdout_1
|
|
|
|
act_1.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
# version: 4.0
|
|
|
|
|
|
|
|
test_script_2 = """
|
|
|
|
set list on;
|
|
|
|
-- Engine version could contain more than one digit in any section or more sections.
|
|
|
|
-- Changed pattern for matching such cases of engine version as:
|
|
|
|
-- '3.2.23' or '3.3.2.1.0.1.2.3.4.5.7' etc
|
|
|
|
select iif( t.ev similar to '[0-9]+.[0-9]+.[0-9]+((.?[0-9]+)*)', substring(ev from 1 for 3), null) as version
|
|
|
|
from (
|
|
|
|
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') ev
|
|
|
|
from rdb$database
|
|
|
|
)t;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
act_2 = isql_act('db', test_script_2, substitutions=[('4\\.\\d+', '4\\.')]
|
|
|
|
)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
expected_stdout_2 = """
|
|
|
|
VERSION 4.0
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
@pytest.mark.version('>=4.0,<5.0')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_2(act_2: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
act_2.expected_stdout = expected_stdout_2
|
|
|
|
act_2.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_2.clean_stdout == act_2.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
# version: 5.0
|
|
|
|
|
|
|
|
test_script_3 = """
|
|
|
|
set list on;
|
|
|
|
-- Engine version could contain more than one digit in any section or more sections.
|
|
|
|
-- Changed pattern for matching such cases of engine version as:
|
|
|
|
-- '3.2.23' or '3.3.2.1.0.1.2.3.4.5.7' etc
|
|
|
|
select iif( t.ev similar to '[0-9]+.[0-9]+.[0-9]+((.?[0-9]+)*)', substring(ev from 1 for 3), null) as version
|
|
|
|
from (
|
|
|
|
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') ev
|
|
|
|
from rdb$database
|
|
|
|
)t;
|
|
|
|
"""
|
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
act_3 = isql_act('db', test_script_3, substitutions=[('5\\.\\d+', '5\\.')])
|
2021-12-30 19:43:52 +01:00
|
|
|
|
|
|
|
expected_stdout_3 = """
|
|
|
|
VERSION 5.0
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=5.0')
|
|
|
|
def test_3(act_3: Action):
|
|
|
|
act_3.expected_stdout = expected_stdout_3
|
|
|
|
act_3.execute()
|
|
|
|
assert act_3.clean_stdout == act_3.clean_expected_stdout
|
|
|
|
|