6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_5092_test.py

205 lines
6.8 KiB
Python

#coding:utf-8
#
# id: bugs.core_5092
# title: ISQL extract command looses COMPUTED BY field types
# decription:
# Test creates database with empty table T1 that has computed by fileds with DDL appopriate to the ticket issues.
# Then we:
# 1) extract metadata from database and store it to <init_meta.sql>;
# 2) run query to the table T1 with setting sqlda_display = ON, and store output to <init_sqlda.log>;
# 3) DROP table T1;
# 4) try to apply script with extracted metadata (see step "1") - it should pass without errors;
# 5) AGAIN extract metadata and store it to <last_meta.sql>;
# 6) AGAIN run query to T1 with set sqlda_display = on, and store output to <last_sqlda.log>;
# 7) compare text files:
# <init_meta.sql> vs <last_meta.sql>
# <init_sqlda.log> vs <last_sqlda.log>
# 8) Check that result of comparison is EMPTY (no rows).
#
# Confirmed bug on 3.0.0.32300, fixed on 3.0.0.32306.
#
# tracker_id: CORE-5092
# min_versions: ['3.0']
# versions: 3.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """
recreate table t1 (
n0 int
,si smallint computed by( 32767 )
,bi bigint computed by ( 2147483647 )
,s2 smallint computed by ( mod(bi, nullif(si,0)) )
,dv double precision computed by (pi())
,fv float computed by (dv*dv)
,nv numeric(3,1) computed by (sqrt(fv))
,dt date computed by ('now')
,tm time computed by ('now')
,dx timestamp computed by ( dt )
,tx timestamp computed by ( tm )
,c1 char character set win1251 computed by ('ы')
,c2 char character set win1252 computed by ('å')
,cu char character set utf8 computed by ('')
,c1x char computed by(c1)
,c2x char computed by(c2)
,cux char computed by(cu)
,b1 blob character set win1251 computed by ('ы')
,b2 blob character set win1252 computed by ('ä')
,bu blob character set utf8 computed by ('')
,bb blob computed by ('')
,b1x blob computed by (b1)
,b2x blob computed by (b2)
,bux blob computed by (bu)
,bbx blob computed by (bb)
);
--insert into t1 values(null);
commit;
"""
db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# test_script_1
#---
# import os
# import time
# import subprocess
# import difflib
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_file = db_conn.database_name
# db_conn.close()
#
# #--------------------------------------------
#
# def flush_and_close(file_handle):
# # https://docs.python.org/2/library/os.html#os.fsync
# # If you're starting with a Python file object f,
# # first do f.flush(), and
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
#
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb') and file_handle.name != os.devnull:
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.close()
#
# #--------------------------------------------
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if type(f_names_list[i]) == file:
# del_name = f_names_list[i].name
# elif type(f_names_list[i]) == str:
# del_name = f_names_list[i]
# else:
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# del_name = None
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
# #--------------------------------------------
#
# f_meta_init_sql = open( os.path.join(context['temp_directory'],'tmp_meta_5092_init.sql'), 'w')
# subprocess.call( [context['isql_path'], dsn, "-x", "-ch", "utf8"],
# stdout = f_meta_init_sql,
# stderr = subprocess.STDOUT
# )
# flush_and_close( f_meta_init_sql )
#
# sqlda_check='set list on; set sqlda_display on; select * from t1; commit; drop table t1; exit;'
#
# f_sqlda_init = open( os.path.join(context['temp_directory'],'tmp_sqlda_5092_init.log'), 'w')
# f_sqlda_init.close()
# runProgram( 'isql',[dsn, '-q', '-m', '-o', f_sqlda_init.name], sqlda_check)
#
# f_apply_meta_log = open( os.path.join(context['temp_directory'],'tmp_meta_5092_apply.log'), 'w')
# subprocess.call( [context['isql_path'], dsn, "-i", f_meta_init_sql.name, "-ch", "utf8" ],
# stdout = f_apply_meta_log,
# stderr = subprocess.STDOUT
# )
# flush_and_close( f_apply_meta_log )
#
# f_meta_last_sql = open( os.path.join(context['temp_directory'],'tmp_meta_5092_last.sql'), 'w')
# subprocess.call( [context['isql_path'], dsn, "-x", "-ch", "utf8"],
# stdout = f_meta_last_sql,
# stderr = subprocess.STDOUT
# )
# flush_and_close( f_meta_last_sql )
#
# f_sqlda_last = open( os.path.join(context['temp_directory'],'tmp_sqlda_5092_last.log') , 'w')
# f_sqlda_last.close()
#
# runProgram( 'isql',[dsn, '-q', '-m', '-o', f_sqlda_last.name], sqlda_check)
#
# f_diff_txt=open( os.path.join(context['temp_directory'],'tmp_5092_meta_diff.txt'), 'w')
#
# f_old=[]
# f_new=[]
#
# f_old.append(f_meta_init_sql)
# f_old.append(f_sqlda_init)
#
# f_new.append(f_meta_last_sql)
# f_new.append(f_sqlda_last)
#
# for i in range(len(f_old)):
# old_file=open(f_old[i].name,'r')
# new_file=open(f_new[i].name,'r')
#
# f_diff_txt.write( ''.join( difflib.unified_diff( old_file.readlines(), new_file.readlines() ) ) )
#
# old_file.close()
# new_file.close()
#
# flush_and_close( f_diff_txt )
#
# # Should be EMPTY:
# ##################
# with open( f_apply_meta_log.name, 'r') as f:
# for line in f:
# print( 'Error log of applying extracted metadata: ' + f.line() )
#
#
# # Should be EMPTY:
# ##################
# with open( f_diff_txt.name,'r') as f:
# for line in f:
# print( ' '.join(line.split()).upper() )
#
#
#
# # Cleanup.
# ##########
# time.sleep(1)
#
# cleanup( (f_meta_init_sql,f_meta_last_sql,f_sqlda_init,f_sqlda_last,f_apply_meta_log,f_diff_txt) )
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
@pytest.mark.version('>=3.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")