mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_7046_test.py: check ability to see comments to mapping in extacted metadata. Replaced text of comments to non-ascii.
This commit is contained in:
parent
4cc1039736
commit
959e5ca3a2
@ -24,19 +24,20 @@ NOTES:
|
||||
3. Value of REQUIRED_ALIAS must be EXACTLY the same as alias specified in the pre-created databases.conf
|
||||
(for LINUX this equality is case-sensitive, even when aliases are compared!)
|
||||
|
||||
::: NB-1 :::
|
||||
CURRENTLY comment for mapping is NOT shown when we extract metadata using isql -x.
|
||||
Because of that, only comment for VIEW is specified in expected text.
|
||||
Test will be adjusted after this issue will be fixed.
|
||||
|
||||
::: NB-2 :::
|
||||
Ability to specify non-ascii comment to mapping was not checked.
|
||||
|
||||
Checked on 5.0.0.958
|
||||
|
||||
[26.06.2023] pzotov
|
||||
Comments to mapping can be seen in extracted metadata since 21.06.2023, see:
|
||||
https://github.com/FirebirdSQL/firebird/commit/15b0b297dcde81cc5e1c38cbd4ea761e27f442bd
|
||||
Added check for this ability.
|
||||
Also, comment text now is non-ascii (decided to use parts of 'lorem ipsum' encoded in armenian and georgian)
|
||||
|
||||
Checked on 5.0.0.1087
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
import locale
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
@ -51,14 +52,14 @@ from firebird.qa import *
|
||||
#
|
||||
REQUIRED_ALIAS = 'tmp_gh_7046_alias'
|
||||
|
||||
db = db_factory()
|
||||
db = db_factory(charset = 'utf8', utf8filename = True)
|
||||
act = python_act('db', substitutions=[('[ \t]+', ' '), ('.*===.*', ''), ('PLUGIN .*', 'PLUGIN'), ('MAP_COMMENT_BLOB_ID .*', 'MAP_COMMENT_BLOB_ID')])
|
||||
|
||||
tmp_file = temp_file('tmp_gh_7046-ddl.sql')
|
||||
fn_meta_log = temp_file('tmp_gh_7046-meta.log')
|
||||
fn_meta_err = temp_file('tmp_gh_7046-meta.err')
|
||||
|
||||
@pytest.mark.version('>=5.0')
|
||||
def test_1(act: Action, fn_meta_log: Path, fn_meta_err: Path, capsys):
|
||||
def test_1(act: Action, tmp_file: Path, fn_meta_log: Path, capsys):
|
||||
|
||||
# Scan line-by-line through databases.conf, find line starting with REQUIRED_ALIAS and extract name of file that
|
||||
# must be created in the $(dir_sampleDb)/qa/ folder. This name will be used further as target database (tmp_fdb).
|
||||
@ -84,14 +85,15 @@ def test_1(act: Action, fn_meta_log: Path, fn_meta_err: Path, capsys):
|
||||
tmp_fdb = Path( act.vars['sample_dir'], 'qa', fname_in_dbconf )
|
||||
|
||||
PLUGIN_FOR_MAPPING = 'Srp'
|
||||
MAPPING_NAME = 'trusted_auth_7046'
|
||||
MAPPING_NAME = 'trusted_auth_7046'.upper()
|
||||
|
||||
# UnicodeEncodeError: charmap codec cant encode characters in position 601-605: character maps to <undefined>
|
||||
MAPPING_COMMENT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'
|
||||
VIEW_COMMENT = 'Audiam legimus mei an, eu possit constituto per, case assentior te usu'
|
||||
MAPPING_COMMENT = u'विभाजन स्वतंत्रता वर्ष बाटते चाहे शीघ्र अत्यंत सार्वजनिक ध्येय सार्वजनिक विश्वव्यापि रखते विवरन भारतीय स्थापित बदले मुख्य कैसे ब्रौशर हुएआदि सामूहिक मजबुत पेदा सार्वजनिक प्राधिकरन बीसबतेबोध बहुत होसके खरिदने उदेशीत विकेन्द्रियकरण मेमत दौरान प्रमान असक्षम नीचे कुशलता और्४५० बिन्दुओ विकास'
|
||||
VIEW_COMMENT = 'լոռեմ իպսում դոլոռ սիթ ամեթ, աթ քուիս քուոդ իուս, սանծթուս լաբոռամուս սենթենթիաե վել ութ. եսթ եի թալե ոմիթթամ սծռիպսեռիթ, սեա հինծ ծիբո ծոնգուե իդ. վոլուպթաթում ռեպռեհենդունթ եամ իդ, եի վեռո նոբիս ծում. ին մեի իլլում ֆածեռ ելիգենդի, եի գռաեծե լաոռեեթ ոֆֆիծիիս եսթ. եոս ծոնգուե ծեթեռոս թե, սաեպե սանծթուս մինիմում նո նամ, իդ նամ սաեպե եուռիպիդիս. եսթ մոդո իուսթո եխ'
|
||||
|
||||
sql_txt = f'''
|
||||
set bail on;
|
||||
set names utf8;
|
||||
set list on;
|
||||
set blob all;
|
||||
create database '{REQUIRED_ALIAS}' user {act.db.user};
|
||||
@ -152,8 +154,9 @@ def test_1(act: Action, fn_meta_log: Path, fn_meta_err: Path, capsys):
|
||||
select * from v_map_info;
|
||||
quit;
|
||||
'''
|
||||
tmp_file.write_bytes(sql_txt.encode('utf8'))
|
||||
|
||||
expected_stdout_isql = f'''
|
||||
expected_stdout_isql = u'''
|
||||
MON_SEC_DB Self
|
||||
|
||||
MAP_NAME TRUSTED_AUTH_7046
|
||||
@ -163,7 +166,7 @@ def test_1(act: Action, fn_meta_log: Path, fn_meta_err: Path, capsys):
|
||||
TO_TYPE 0
|
||||
MAP_TO <null>
|
||||
MAP_COMMENT_BLOB_ID 2d:1e0
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
||||
%(MAPPING_COMMENT)s
|
||||
|
||||
MAP_NAME TRUSTED_AUTH_7046
|
||||
MAP_TYPE GLOBAL
|
||||
@ -172,41 +175,42 @@ def test_1(act: Action, fn_meta_log: Path, fn_meta_err: Path, capsys):
|
||||
TO_TYPE 0
|
||||
MAP_TO <null>
|
||||
MAP_COMMENT_BLOB_ID 0:2
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
|
||||
%(MAPPING_COMMENT)s
|
||||
|
||||
Records affected: 2
|
||||
'''
|
||||
''' % locals()
|
||||
|
||||
try:
|
||||
act.expected_stdout = expected_stdout_isql
|
||||
act.isql(switches = ['-q'], input = sql_txt, connect_db=False, credentials = False, combine_output = True, io_enc = locale.getpreferredencoding(), charset = 'utf8')
|
||||
act.isql(switches = ['-q'], input_file=tmp_file, connect_db=False, credentials = False, combine_output = True, io_enc = 'utf8', charset = 'utf8')
|
||||
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
||||
act.reset()
|
||||
|
||||
|
||||
with fn_meta_log.open(mode='w') as meta_out, fn_meta_err.open(mode='w') as meta_err:
|
||||
with fn_meta_log.open(mode='w') as meta_out:
|
||||
# could not find how properly call act.extract_meta with ANOTHER database (different from currently created).
|
||||
subprocess.call( [ act.vars['isql'],'-x', '-user', act.db.user, '-pas', act.db.password, REQUIRED_ALIAS ],
|
||||
subprocess.call( [ act.vars['isql'],'-ch', 'utf8', '-x', '-user', act.db.user, '-pas', act.db.password, REQUIRED_ALIAS ],
|
||||
stdout = meta_out,
|
||||
stderr = meta_err
|
||||
stderr = subprocess.STDOUT
|
||||
)
|
||||
|
||||
for g in (fn_meta_log, fn_meta_err):
|
||||
with g.open() as f:
|
||||
with codecs.open(fn_meta_log, 'r', encoding='utf8') as f:
|
||||
for line in f:
|
||||
if line.split():
|
||||
if g == fn_meta_log:
|
||||
if ' MAPPING ' in line or 'COMMENT ON ' in line:
|
||||
print(f'{line}')
|
||||
else:
|
||||
print(f'UNEXPECTED MATADATA STDOUT: {line}')
|
||||
print(u'%(line)s' % locals())
|
||||
elif 'SQLSTATE' in line:
|
||||
print('UNEXPECTED ERROR: ',line)
|
||||
|
||||
act.expected_stdout = u"""
|
||||
CREATE MAPPING %(MAPPING_NAME)s USING PLUGIN
|
||||
CREATE OR ALTER GLOBAL MAPPING %(MAPPING_NAME)s USING PLUGIN
|
||||
COMMENT ON VIEW V_MAP_INFO IS '%(VIEW_COMMENT)s';
|
||||
COMMENT ON MAPPING TRUSTED_AUTH_7046 IS '%(MAPPING_COMMENT)s';
|
||||
COMMENT ON GLOBAL MAPPING TRUSTED_AUTH_7046 IS '%(MAPPING_COMMENT)s';
|
||||
""" % locals()
|
||||
|
||||
act.expected_stdout = f"""
|
||||
CREATE MAPPING {MAPPING_NAME.upper()} USING PLUGIN
|
||||
CREATE OR ALTER GLOBAL MAPPING {MAPPING_NAME.upper()} USING PLUGIN
|
||||
COMMENT ON VIEW V_MAP_INFO IS '{VIEW_COMMENT}';
|
||||
"""
|
||||
|
||||
finally:
|
||||
tmp_fdb.unlink()
|
||||
|
Loading…
Reference in New Issue
Block a user