11# coding: utf-8
2- import os
32
4- import pytest
3+ from .helpers .os_ops_descrs import OsOpsDescrs
4+ from .helpers .os_ops_descrs import OsOperations
55
66from ..testgres import ExecUtilException
7- from ..testgres import RemoteOperations
8- from ..testgres import ConnectionParams
7+
8+ import os
9+ import pytest
910
1011
1112class TestRemoteOperations :
13+ @pytest .fixture
14+ def os_ops (self ):
15+ return OsOpsDescrs .sm_remote_os_ops
1216
13- @pytest .fixture (scope = "function" ,autouse = True )
14- def setup (self ):
15- conn_params = ConnectionParams (host = os .getenv ('RDBMS_TESTPOOL1_HOST' )or '127.0.0.1' ,
16- username = os .getenv ('USER' ),
17- ssh_key = os .getenv ('RDBMS_TESTPOOL_SSHKEY' ))
18- self .operations = RemoteOperations (conn_params )
17+ def test_rmdirs__try_to_delete_nonexist_path (self ,os_ops :OsOperations ):
18+ assert isinstance (os_ops ,OsOperations )
1919
20- def test_rmdirs__try_to_delete_nonexist_path (self ):
2120path = "/root/test_dir"
2221
23- assert self .operations .rmdirs (path ,ignore_errors = False )is True
22+ assert os_ops .rmdirs (path ,ignore_errors = False )is True
23+
24+ def test_rmdirs__try_to_delete_file (self ,os_ops :OsOperations ):
25+ assert isinstance (os_ops ,OsOperations )
2426
25- def test_rmdirs__try_to_delete_file ( self ):
26- path = self . operations . mkstemp ()
27+ path = os_ops . mkstemp ()
28+ assert type ( path ) == str # noqa: E721
2729assert os .path .exists (path )
2830
2931with pytest .raises (ExecUtilException )as x :
30- self . operations .rmdirs (path ,ignore_errors = False )
32+ os_ops .rmdirs (path ,ignore_errors = False )
3133
3234assert os .path .exists (path )
3335assert type (x .value )== ExecUtilException # noqa: E721
@@ -37,37 +39,40 @@ def test_rmdirs__try_to_delete_file(self):
3739assert type (x .value .exit_code )== int # noqa: E721
3840assert x .value .exit_code == 20
3941
40- def test_read__unknown_file (self ):
42+ def test_read__unknown_file (self , os_ops : OsOperations ):
4143"""
4244 Test RemoteOperations::read with unknown file.
4345 """
46+ assert isinstance (os_ops ,OsOperations )
4447
4548with pytest .raises (ExecUtilException )as x :
46- self . operations .read ("/dummy" )
49+ os_ops .read ("/dummy" )
4750
4851assert "Utility exited with non-zero code (1)." in str (x .value )
4952assert "No such file or directory" in str (x .value )
5053assert "/dummy" in str (x .value )
5154
52- def test_read_binary__spec__unk_file (self ):
55+ def test_read_binary__spec__unk_file (self , os_ops : OsOperations ):
5356"""
5457 Test RemoteOperations::read_binary with unknown file.
5558 """
59+ assert isinstance (os_ops ,OsOperations )
5660
5761with pytest .raises (ExecUtilException )as x :
58- self . operations .read_binary ("/dummy" ,0 )
62+ os_ops .read_binary ("/dummy" ,0 )
5963
6064assert "Utility exited with non-zero code (1)." in str (x .value )
6165assert "No such file or directory" in str (x .value )
6266assert "/dummy" in str (x .value )
6367
64- def test_get_file_size__unk_file (self ):
68+ def test_get_file_size__unk_file (self , os_ops : OsOperations ):
6569"""
6670 Test RemoteOperations::get_file_size.
6771 """
72+ assert isinstance (os_ops ,OsOperations )
6873
6974with pytest .raises (ExecUtilException )as x :
70- self . operations .get_file_size ("/dummy" )
75+ os_ops .get_file_size ("/dummy" )
7176
7277assert "Utility exited with non-zero code (1)." in str (x .value )
7378assert "No such file or directory" in str (x .value )