@@ -50,18 +50,19 @@ def dst_path(file_paths_pair):
50
50
return path
51
51
52
52
53
- @pytest .fixture
54
- def other_payload ():
55
- """Generate a binary test payload."""
56
- uuid_name = uuid .uuid4 ()
57
- return 'Original content: {name!s}' .format (name = uuid_name ).encode ()
53
+ @pytest .fixture (params = [32 , 1025 ])
54
+ def sized_payload ():
55
+ """Generate a binary test payload of size given as a parameter."""
56
+ payload_len = 1024 + 1
57
+ random_bytes = [ord (random .choice (string .printable )) for _ in range (payload_len )]
58
+ return bytes (random_bytes )
58
59
59
60
60
61
@pytest .fixture
61
- def dst_exists_path (file_paths_pair , other_payload ):
62
+ def dst_exists_path (file_paths_pair , sized_payload ):
62
63
"""Return a data destination path."""
63
64
path = file_paths_pair [1 ]
64
- path .write_bytes (other_payload )
65
+ path .write_bytes (sized_payload )
65
66
assert path .exists ()
66
67
return path
67
68
@@ -96,32 +97,24 @@ def test_put_existing(dst_exists_path, src_path, sftp_session, transmit_payload)
96
97
97
98
98
99
@pytest .fixture
99
- def large_payload ():
100
- """Generate a large 1025 byte (1024 + 1B) test payload."""
101
- payload_len = 1024 + 1
102
- random_bytes = [ord (random .choice (string .printable )) for _ in range (payload_len )]
103
- return bytes (random_bytes )
104
-
105
-
106
- @pytest .fixture
107
- def src_path_large (tmp_path , large_payload ):
100
+ def src_path_large (tmp_path , sized_payload ):
108
101
"""Return a remote path to a 1025 byte-sized file.
109
102
110
103
The pylibssh chunk size is 1024 so the test needs a file that would
111
104
execute at least two loops.
112
105
"""
113
106
path = tmp_path / 'large.txt'
114
- path .write_bytes (large_payload )
107
+ path .write_bytes (sized_payload )
115
108
return path
116
109
117
110
118
- def test_put_large (dst_path , src_path_large , sftp_session , large_payload ):
111
+ def test_put_large (dst_path , src_path_large , sftp_session , sized_payload ):
119
112
"""Check that SFTP can upload large file."""
120
113
sftp_session .put (str (src_path_large ), str (dst_path ))
121
- assert dst_path .read_bytes () == large_payload
114
+ assert dst_path .read_bytes () == sized_payload
122
115
123
116
124
- def test_get_large (dst_path , src_path_large , sftp_session , large_payload ):
117
+ def test_get_large (dst_path , src_path_large , sftp_session , sized_payload ):
125
118
"""Check that SFTP can download large file."""
126
119
sftp_session .get (str (src_path_large ), str (dst_path ))
127
- assert dst_path .read_bytes () == large_payload
120
+ assert dst_path .read_bytes () == sized_payload
0 commit comments