Skip to content

Commit 64d6bc2

Browse files
committed
Added/Updated tests\bugs\gh_8066_test.py: Checked on 6.0.0.344, 5.0.1.1394, 4.0.5.3091.
1 parent bd1b175 commit 64d6bc2

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/bugs/gh_8066_test.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#coding:utf-8
2+
3+
"""
4+
ID: issue-8066
5+
ISSUE: 8066
6+
TITLE: Make protocol schemes case-insensitive
7+
DESCRIPTION:
8+
Test iterates over all possible protocols (depending on OS and engine major version): INET(4|6), WNET, XNET.
9+
Then connection string is made using three cases of protocol string: lower, UPPER and Capitalized.
10+
For each kind of DSN we request mon$attachment.mon$remote_protocol value - it must correspond to DSN but
11+
always must be in upper case.
12+
Expected output must not contain any error and must contain appropriate values for every checked protocol
13+
(see 'mon_remote_value')
14+
We have to construct this string 'on the fly' because avaliable protocols depend on OS and major version
15+
(see 'expected_out_lines')
16+
NOTES:
17+
[06.05.2024] pzotov
18+
Checked on 6.0.0.344, 5.0.1.1394, 4.0.5.3091.
19+
"""
20+
21+
import pytest
22+
from firebird.qa import *
23+
from firebird.driver import NetProtocol, ShutdownMode, ShutdownMethod
24+
import locale
25+
import re
26+
27+
db = db_factory()
28+
29+
act = python_act('db', substitutions = [('[ \t]+', ' ')])
30+
31+
@pytest.mark.version('>=4.0.5')
32+
def test_1(act: Action, capsys):
33+
34+
expected_out_lines = []
35+
checked_dsn_column='checked_dsn_prefix'.upper()
36+
mon_remote_column='mon_remote_protocol'.upper()
37+
try:
38+
protocols_list = [ NetProtocol.INET4, NetProtocol.INET, ]
39+
40+
if act.platform == 'Windows':
41+
protocols_list.append(NetProtocol.XNET)
42+
if act.is_version('<5'):
43+
protocols_list.append(NetProtocol.WNET)
44+
45+
for p in protocols_list:
46+
for k in range(3):
47+
protocol_str = p.name.lower() if k == 0 else p.name.upper() if k==1 else p.name.title()
48+
mon_remote_value = 'TCPv4' if p.name.lower() == 'inet4' else 'TCPv6' if p.name.lower() == 'inet' else p.name.upper()
49+
dsn = protocol_str + '://' + str(act.db.db_path)
50+
test_sql = f"""
51+
set bail on;
52+
set list on;
53+
connect {dsn};
54+
select '{protocol_str}' as {checked_dsn_column}, mon$remote_protocol as {mon_remote_column} from mon$attachments where mon$attachment_id = current_connection;
55+
quit;
56+
"""
57+
act.isql(switches=['-q'], input = test_sql, io_enc = locale.getpreferredencoding(), combine_output = True, connect_db = False)
58+
expected_out_lines.append(f'{checked_dsn_column} {protocol_str}')
59+
expected_out_lines.append(f'{mon_remote_column} {mon_remote_value}')
60+
print(act.stdout)
61+
62+
except Exception as e:
63+
print(e.__str__())
64+
65+
act.expected_stdout = '\n'.join( expected_out_lines )
66+
act.stdout = capsys.readouterr().out
67+
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)