mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\core_5790_test.py: refactored: make code more robust when FB major version changes. Removed unneeded parts of code.
This commit is contained in:
parent
8de6057b4a
commit
5c93362438
@ -15,55 +15,60 @@ from firebird.qa import *
|
|||||||
|
|
||||||
db = db_factory()
|
db = db_factory()
|
||||||
|
|
||||||
act = python_act('db', substitutions=[('Commit current transaction \\(y/n\\)\\?', '')])
|
act = python_act('db')
|
||||||
|
|
||||||
expected_stdout = """
|
|
||||||
RDB$USER TMP$C5790
|
|
||||||
RDB$GRANTOR SYSDBA
|
|
||||||
RDB$PRIVILEGE O
|
|
||||||
RDB$GRANT_OPTION 0
|
|
||||||
RDB$RELATION_NAME SQL$DATABASE
|
|
||||||
RDB$FIELD_NAME <null>
|
|
||||||
RDB$USER_TYPE 8
|
|
||||||
rdb_object_type_is_expected ? YES
|
|
||||||
Records affected: 1
|
|
||||||
Records affected: 0
|
|
||||||
"""
|
|
||||||
|
|
||||||
test_user = user_factory('db', name='tmp$c5790', password='123')
|
test_user = user_factory('db', name='tmp$c5790', password='123')
|
||||||
fdb_file = temp_file('tmp_5790.fdb')
|
fdb_file = temp_file('tmp_5790.fdb')
|
||||||
|
|
||||||
@pytest.mark.version('>=3.0.4')
|
@pytest.mark.version('>=3.0.4')
|
||||||
def test_1(act: Action, test_user: User, fdb_file: Path):
|
def test_1(act: Action, test_user: User, fdb_file: Path):
|
||||||
|
if act.is_version('>=4'):
|
||||||
|
expected_obj_type = 21
|
||||||
|
elif act.is_version('>=3'):
|
||||||
|
expected_obj_type = 20
|
||||||
|
|
||||||
|
expected_stdout = f"""
|
||||||
|
RDB$USER TMP$C5790
|
||||||
|
RDB$GRANTOR SYSDBA
|
||||||
|
RDB$PRIVILEGE O
|
||||||
|
RDB$GRANT_OPTION 0
|
||||||
|
RDB$RELATION_NAME SQL$DATABASE
|
||||||
|
RDB$FIELD_NAME <null>
|
||||||
|
RDB$USER_TYPE 8
|
||||||
|
RDB$OBJECT_TYPE {expected_obj_type}
|
||||||
|
Records affected: 1
|
||||||
|
Records affected: 0
|
||||||
|
"""
|
||||||
|
|
||||||
act.expected_stdout = expected_stdout
|
act.expected_stdout = expected_stdout
|
||||||
test_script = f"""
|
test_script = f"""
|
||||||
create database 'localhost:{fdb_file}';
|
create database 'localhost:{fdb_file}';
|
||||||
alter database set linger to 0;
|
alter database set linger to 0;
|
||||||
commit;
|
commit;
|
||||||
grant drop database to {test_user.name};
|
grant drop database to {test_user.name};
|
||||||
commit;
|
commit;
|
||||||
connect 'localhost:{fdb_file}' user {test_user.name} password '{test_user.password}';
|
connect 'localhost:{fdb_file}' user {test_user.name} password '{test_user.password}';
|
||||||
set list on;
|
set list on;
|
||||||
set count on;
|
set count on;
|
||||||
select
|
select
|
||||||
r.rdb$user -- {test_user.name}
|
r.rdb$user -- {test_user.name}
|
||||||
,r.rdb$grantor -- sysdba
|
,r.rdb$grantor -- sysdba
|
||||||
,r.rdb$privilege -- o
|
,r.rdb$privilege -- o
|
||||||
,r.rdb$grant_option -- 0
|
,r.rdb$grant_option -- 0
|
||||||
,r.rdb$relation_name -- sql$database
|
,r.rdb$relation_name -- sql$database
|
||||||
,r.rdb$field_name -- <null>
|
,r.rdb$field_name -- <null>
|
||||||
,r.rdb$user_type -- 8
|
,r.rdb$user_type -- 8
|
||||||
,iif( r.rdb$object_type = decode( left(rdb$get_context('SYSTEM', 'ENGINE_VERSION'),1), '3',20, '4',21, '5', 21), 'YES', 'NO: ' || r.rdb$object_type) "rdb_object_type_is_expected ?"
|
,r.rdb$object_type
|
||||||
from rdb$user_privileges r
|
from rdb$user_privileges r
|
||||||
where r.rdb$user=upper('{test_user.name}');
|
where r.rdb$user=upper('{test_user.name}');
|
||||||
|
|
||||||
-- this should NOT show any attachments: "Records affected: 0" must be shown here.
|
-- this should NOT show any attachments: "Records affected: 0" must be shown here.
|
||||||
select * from mon$attachments where mon$attachment_id != current_connection;
|
select * from mon$attachments where mon$attachment_id != current_connection;
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
drop database;
|
drop database;
|
||||||
rollback;
|
rollback;
|
||||||
"""
|
"""
|
||||||
act.isql(switches=['-q'], input=test_script)
|
act.isql(switches=['-q'], input = test_script, connect_db = False, combine_output = True)
|
||||||
assert act.clean_stdout == act.clean_expected_stdout
|
assert act.clean_stdout == act.clean_expected_stdout
|
||||||
assert not fdb_file.exists()
|
assert not fdb_file.exists()
|
||||||
|
Loading…
Reference in New Issue
Block a user