1
1
# coding: utf-8
2
- import os
3
2
4
- import pytest
3
+ from .helpers .os_ops_descrs import OsOpsDescrs
4
+ from .helpers .os_ops_descrs import OsOperations
5
5
6
6
from ..testgres import ExecUtilException
7
- from ..testgres import RemoteOperations
8
- from ..testgres import ConnectionParams
7
+
8
+ import os
9
+ import pytest
9
10
10
11
11
12
class TestRemoteOperations :
13
+ @pytest .fixture
14
+ def os_ops (self ):
15
+ return OsOpsDescrs .sm_remote_os_ops
12
16
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 )
19
19
20
- def test_rmdirs__try_to_delete_nonexist_path (self ):
21
20
path = "/root/test_dir"
22
21
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 )
24
26
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
27
29
assert os .path .exists (path )
28
30
29
31
with pytest .raises (ExecUtilException ) as x :
30
- self . operations .rmdirs (path , ignore_errors = False )
32
+ os_ops .rmdirs (path , ignore_errors = False )
31
33
32
34
assert os .path .exists (path )
33
35
assert type (x .value ) == ExecUtilException # noqa: E721
@@ -37,37 +39,40 @@ def test_rmdirs__try_to_delete_file(self):
37
39
assert type (x .value .exit_code ) == int # noqa: E721
38
40
assert x .value .exit_code == 20
39
41
40
- def test_read__unknown_file (self ):
42
+ def test_read__unknown_file (self , os_ops : OsOperations ):
41
43
"""
42
44
Test RemoteOperations::read with unknown file.
43
45
"""
46
+ assert isinstance (os_ops , OsOperations )
44
47
45
48
with pytest .raises (ExecUtilException ) as x :
46
- self . operations .read ("/dummy" )
49
+ os_ops .read ("/dummy" )
47
50
48
51
assert "Utility exited with non-zero code (1)." in str (x .value )
49
52
assert "No such file or directory" in str (x .value )
50
53
assert "/dummy" in str (x .value )
51
54
52
- def test_read_binary__spec__unk_file (self ):
55
+ def test_read_binary__spec__unk_file (self , os_ops : OsOperations ):
53
56
"""
54
57
Test RemoteOperations::read_binary with unknown file.
55
58
"""
59
+ assert isinstance (os_ops , OsOperations )
56
60
57
61
with pytest .raises (ExecUtilException ) as x :
58
- self . operations .read_binary ("/dummy" , 0 )
62
+ os_ops .read_binary ("/dummy" , 0 )
59
63
60
64
assert "Utility exited with non-zero code (1)." in str (x .value )
61
65
assert "No such file or directory" in str (x .value )
62
66
assert "/dummy" in str (x .value )
63
67
64
- def test_get_file_size__unk_file (self ):
68
+ def test_get_file_size__unk_file (self , os_ops : OsOperations ):
65
69
"""
66
70
Test RemoteOperations::get_file_size.
67
71
"""
72
+ assert isinstance (os_ops , OsOperations )
68
73
69
74
with pytest .raises (ExecUtilException ) as x :
70
- self . operations .get_file_size ("/dummy" )
75
+ os_ops .get_file_size ("/dummy" )
71
76
72
77
assert "Utility exited with non-zero code (1)." in str (x .value )
73
78
assert "No such file or directory" in str (x .value )
0 commit comments