From 264a8864e91d5f0a8abe26f3874bda7f535300bc Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Wed, 30 Oct 2024 23:44:28 +0300 Subject: [PATCH] Added/Updated tests\bugs\core_3489_test.py: Re-implemented. See notes. Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.2.32670, 3,0,1,32609 --- tests/bugs/core_3489_test.py | 168 +++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 66 deletions(-) diff --git a/tests/bugs/core_3489_test.py b/tests/bugs/core_3489_test.py index f959cf20..48bde78d 100644 --- a/tests/bugs/core_3489_test.py +++ b/tests/bugs/core_3489_test.py @@ -1,66 +1,102 @@ -#coding:utf-8 - -""" -ID: issue-3848 -ISSUE: 3848 -TITLE: Blob transliteration may not happen inside the union -DESCRIPTION: -JIRA: CORE-3489 -FBTEST: bugs.core_3489 -NOTES: - [06.10.2022] pzotov - Could not complete adjusting for LINUX in new-qa. - DEFERRED. -""" -import platform -import pytest -from pathlib import Path -from firebird.qa import * - -init_script = """ - set term ^; - create or alter procedure sp_test - returns ( - msg_blob_id blob sub_type 1 segment size 80 character set unicode_fss) - AS - begin - msg_blob_id= 'Это проверка на вывод строки "Йцукёнг"'; -- text in cyrillic - suspend; - end - ^ - set term ;^ - commit; -""" - -db = db_factory(charset='WIN1251', init=init_script) - -act = python_act('db', substitutions=[('MSG_BLOB_ID.*', '')]) - -expected_stdout = """ - Это проверка на вывод строки "Йцукёнг" - Это проверка на вывод строки "Йцукёнг" - Records affected: 2 -""" - -script_file = temp_file('test_script.sql') - -@pytest.mark.skipif(platform.system() != 'Windows', reason='FIXME: see notes') -@pytest.mark.version('>=3') -def test_1(act: Action, script_file: Path): - script_file.write_text(""" - set list on; - set blob all; - set count on; - set list on; - - select msg_blob_id - from sp_test - union - select msg_blob_id - from sp_test; - """, encoding='cp1251') - act.expected_stdout = expected_stdout - act.isql(switches=[], input_file=script_file, charset='WIN1251') - assert act.clean_stdout == act.clean_expected_stdout - - +#coding:utf-8 + +""" +ID: issue-3848 +ISSUE: 3848 +TITLE: Blob transliteration may not happen inside the union +DESCRIPTION: +JIRA: CORE-3489 +FBTEST: bugs.core_3489 +NOTES: + [30.10.2024] pzotov + Bug was fixed for too old FB (3.0 Alpha 1), firebird-driver and/or QA-plugin will not able to run on this version. + to check this version in order to reproduce problem. + Source for this test was taken from ticket almost w/o changes. Only aux view has been added ('v_conn_cset') for + showing current connection protocol and character set - we make query to this view two twice: one for TCP and then + for local protocol. + + Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.2.32670, 3,0,1,32609 +""" + +import locale +from pathlib import Path +import pytest +from firebird.qa import * + +db = db_factory(charset='WIN1251') + +act = python_act('db', substitutions=[('MSG_BLOB_ID.*', ''), ('TCPv(4|6)', 'TCP')]) + +expected_stdout = """ + CONN_PROTOCOL TCP + CONNECTION_CSET WIN1251 + DB_DEFAULT_CSET WIN1251 + Records affected: 1 + Это проверка на вывод строки "Йцукёнг" + Это проверка на вывод строки "Йцукёнг" + Records affected: 2 + + CONN_PROTOCOL + CONNECTION_CSET WIN1251 + DB_DEFAULT_CSET WIN1251 + Records affected: 1 + Это проверка на вывод строки "Йцукёнг" + Это проверка на вывод строки "Йцукёнг" + Records affected: 2 +""" + +tmp_sql = temp_file('tmp_core_3489.sql') + +@pytest.mark.version('>=3.0.0') +def test_1(act: Action, tmp_sql: Path): + tmp_sql.write_text( + f""" + set bail on; + set list on; + set blob all; + set count on; + set names win1251; + connect '{act.db.dsn}'; + create view v_conn_cset as + select + rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') as conn_protocol + ,c.rdb$character_set_name as connection_cset + ,r.rdb$character_set_name as db_default_cset + from mon$attachments a + join rdb$character_sets c on a.mon$character_set_id = c.rdb$character_set_id + cross join rdb$database r where a.mon$attachment_id=current_connection; + + set term ^; + create or alter procedure sp_test + returns ( + msg_blob_id blob sub_type 1 segment size 80 character set unicode_fss) + AS + begin + msg_blob_id= 'Это проверка на вывод строки "Йцукёнг"'; -- text in cyrillic + suspend; + end + ^ + set term ;^ + commit; + -------------------------- + connect '{act.db.dsn}'; -- check TCP protocol + select * from v_conn_cset; + select msg_blob_id + from sp_test + union + select msg_blob_id + from sp_test; + commit; + -------------------------- + connect '{act.db.db_path}'; -- check local protocol + select * from v_conn_cset; + select msg_blob_id + from sp_test + union + select msg_blob_id + from sp_test; + """ + ,encoding='cp1251') + act.expected_stdout = expected_stdout + act.isql(switches = ['-q'], input_file = tmp_sql, charset = 'WIN1251', combine_output = True, connect_db = False) + assert act.clean_stdout == act.clean_expected_stdout