|
5 | 5 |
|
6 | 6 | Authors: Rasmus Welander, Diogo Castro, Giuseppe Lo Presti. |
7 | 7 | |
8 | | -Last updated: 26/07/2024 |
| 8 | +Last updated: 19/08/2024 |
9 | 9 |
|
10 | 10 | """ |
11 | 11 |
|
|
17 | 17 | from file import File |
18 | 18 | from auth import Auth |
19 | 19 | from user import User |
| 20 | +from statuscodehandler import StatusCodeHandler |
| 21 | +from share import Share |
| 22 | +from app import App |
| 23 | +from checkpoint import Checkpoint |
20 | 24 | from config import Config |
21 | 25 | import base64 |
22 | 26 | import json |
@@ -63,7 +67,17 @@ def create_mock_jwt(): |
63 | 67 |
|
64 | 68 | @pytest.fixture |
65 | 69 | def mock_logger(): |
66 | | - return Mock() |
| 70 | + logger = Mock() |
| 71 | + logger.info = Mock() |
| 72 | + logger.error = Mock() |
| 73 | + logger.debug = Mock() |
| 74 | + logger.warning = Mock() |
| 75 | + return logger |
| 76 | + |
| 77 | + |
| 78 | +@pytest.fixture |
| 79 | +def mock_status_code_handler(mock_logger, mock_config): |
| 80 | + return StatusCodeHandler(mock_logger, Config(mock_config, "cs3client")) |
67 | 81 |
|
68 | 82 |
|
69 | 83 | # Here the order of patches correspond to the parameters of the function |
@@ -153,14 +167,46 @@ def cs3_client_insecure( |
153 | 167 | return client |
154 | 168 |
|
155 | 169 |
|
| 170 | +@pytest.fixture |
| 171 | +def app_instance(mock_authentication, mock_gateway, mock_config, mock_logger, mock_status_code_handler): |
| 172 | + app = App( |
| 173 | + Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication, mock_status_code_handler |
| 174 | + ) |
| 175 | + return app |
| 176 | + |
| 177 | + |
| 178 | +@pytest.fixture |
| 179 | +def checkpoint_instance(mock_authentication, mock_gateway, mock_config, mock_logger, mock_status_code_handler): |
| 180 | + checkpoint = Checkpoint( |
| 181 | + Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication, mock_status_code_handler |
| 182 | + ) |
| 183 | + return checkpoint |
| 184 | + |
| 185 | + |
| 186 | +@pytest.fixture |
| 187 | +def share_instance(mock_authentication, mock_gateway, mock_config, mock_logger, mock_status_code_handler): |
| 188 | + share = Share( |
| 189 | + Config(mock_config, "cs3client"), |
| 190 | + mock_logger, |
| 191 | + mock_gateway, |
| 192 | + mock_authentication, |
| 193 | + mock_status_code_handler, |
| 194 | + ) |
| 195 | + return share |
| 196 | + |
| 197 | + |
156 | 198 | # All parameters are inferred by pytest from existing fixtures |
157 | 199 | @pytest.fixture |
158 | | -def file_instance(mock_authentication, mock_gateway, mock_config, mock_logger): |
159 | | - file = File(Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication) |
| 200 | +def file_instance(mock_authentication, mock_gateway, mock_config, mock_logger, mock_status_code_handler): |
| 201 | + file = File( |
| 202 | + Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication, mock_status_code_handler |
| 203 | + ) |
160 | 204 | return file |
161 | 205 |
|
162 | 206 |
|
163 | 207 | @pytest.fixture |
164 | | -def user_instance(mock_authentication, mock_gateway, mock_config, mock_logger): |
165 | | - user = User(Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication) |
| 208 | +def user_instance(mock_authentication, mock_gateway, mock_config, mock_logger, mock_status_code_handler): |
| 209 | + user = User( |
| 210 | + Config(mock_config, "cs3client"), mock_logger, mock_gateway, mock_authentication, mock_status_code_handler |
| 211 | + ) |
166 | 212 | return user |
0 commit comments