From 1042d0380dbd0498cd76c8796dca23fcd3ece856 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Mon, 22 Jul 2024 20:04:50 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_6267_test.py: Checked on 6.0.0.396, 5.0.1.1440, 4.0.5.3127 --- tests/bugs/gh_6267_test.py | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/bugs/gh_6267_test.py diff --git a/tests/bugs/gh_6267_test.py b/tests/bugs/gh_6267_test.py new file mode 100644 index 00000000..e5fa01c1 --- /dev/null +++ b/tests/bugs/gh_6267_test.py @@ -0,0 +1,43 @@ +#coding:utf-8 + +""" +ID: issue-6267 +ISSUE: https://github.com/FirebirdSQL/firebird/issues/6267 +TITLE: Add transaction info fb_info_tra_snapshot_number [CORE6017] +DESCRIPTION: + Test verifies ability to use appropriate API info and whether value of + returned snapshot_number equals to RDB$GET_CONTEXT('SYSTEM', 'SNAPSHOT_NUMBER'). +NOTES: + [22.07.2024] pzotov + Checked on 6.0.0.396, 5.0.1.1440, 4.0.5.3127 +""" + +import pytest +from firebird.qa import * +from firebird.driver import tpb, Isolation + +db = db_factory() +act = python_act('db') + +CUSTOM_TPB = tpb(isolation = Isolation.SNAPSHOT) + +@pytest.mark.version('>=4.0') +def test_1(act: Action, capsys): + with act.db.connect() as con: + tx1 = con.transaction_manager(CUSTOM_TPB) + tx1.begin() + cur1 = tx1.cursor() + + cur1.execute("select RDB$GET_CONTEXT('SYSTEM', 'SNAPSHOT_NUMBER') from rdb$database") + ctx_sn = int(cur1.fetchone()[0]) + if ctx_sn == tx1.info.snapshot_number: + print('OK') + else: + print(f'MISMATCH: RDB$GET_CONTEXT={ctx_sn}, {tx1.info.snapshot_number=}') + tx1.commit() + + act.expected_stdout = """ + OK + """ + act.stdout = capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout