6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-02-02 02:40:42 +01:00

Added/Updated tests\functional\gtcs\test_isql_show_command_collation.py: refactored: removed SHOW commands. It is enough to extract metadata and APPLY it to test DB. See notes.

This commit is contained in:
pavel-zotov 2023-10-07 12:15:24 +03:00
parent c6e6ebe531
commit c3c9c9762e

View File

@ -10,47 +10,54 @@ DESCRIPTION:
bug #223126 Misplaced collation when extracting metadata with isql
FBTEST: functional.gtcs.isql_show_command_collation
NOTES:
[07.10.2023] pzotov.
1. Removed SHOW commands for check result because their output often changes.
2. It is enough to extract metadata and APPLY it to test DB (with dropping previously created objects). No error must raise.
"""
import pytest
from firebird.qa import *
db = db_factory()
test_script = """
init_sql = """
create domain domain_with_collate_clause as char(1)
character set iso8859_1
default 'v'
check(value >='a' and value <='z')
collate es_es;
commit;
create table table_with_collated_field (
field_01 domain_with_collate_clause
default 'w'
collate pt_pt
);
alter table table_with_collated_field add constraint f01_check check( field_01 >= 'c' );
show domain domain_with_collate_clause;
show table table_with_collated_field;
"""
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')])
expected_stdout = """
DOMAIN_WITH_COLLATE_CLAUSE CHAR(1) CHARACTER SET ISO8859_1 Nullable
default 'v'
check(value >='a' and value <='z')
COLLATE ES_ES
FIELD_01 (DOMAIN_WITH_COLLATE_CLAUSE) CHAR(1) CHARACTER SET ISO8859_1 Nullable default 'w'
check(value >='a' and value <='z')
COLLATE PT_PT
CONSTRAINT F01_CHECK:
check( field_01 >= 'c' )
commit;
"""
db = db_factory(init = init_sql)
act = python_act('db')
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
def test_1(act: Action, capsys):
act.isql(switches=['-x'])
init_metadata = act.stdout
act.reset()
#--------------------------------------------------------------------
drop_sql = """
drop table table_with_collated_field;
drop domain domain_with_collate_clause;
commit;
"""
act.isql(switches = ['-q'], input = drop_sql, combine_output = True)
assert act.clean_stdout == '' # no errors must occur when drop previously created table and domain
act.reset()
#--------------------------------------------------------------------
# Apply extracted metadata
#act.isql(switches = ['-q'], input = '\n'.join(init_metadata), combine_output = True)
act.isql(switches = ['-q'], input = init_metadata, combine_output = True)
assert act.clean_stdout == '' # no errors must occur while applying script with extracted metadata
act.reset()
#print(init_metadata)
#act.stdout = capsys.readouterr().out
#assert act.clean_stdout == act.clean_expected_stdout