Skip to content

Commit c7dfea3

Browse files
Rasmus Oscar Welanderglpatcern
authored andcommitted
Parameterized tests
1 parent eabf899 commit c7dfea3

File tree

3 files changed

+357
-613
lines changed

3 files changed

+357
-613
lines changed

tests/fixtures.py

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Authors: Rasmus Welander, Diogo Castro, Giuseppe Lo Presti.
77
8-
Last updated: 26/07/2024
8+
Last updated: 19/08/2024
99
1010
"""
1111

@@ -17,6 +17,10 @@
1717
from file import File
1818
from auth import Auth
1919
from user import User
20+
from statuscodehandler import StatusCodeHandler
21+
from share import Share
22+
from app import App
23+
from checkpoint import Checkpoint
2024
from config import Config
2125
import base64
2226
import json
@@ -63,7 +67,17 @@ def create_mock_jwt():
6367

6468
@pytest.fixture
6569
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"))
6781

6882

6983
# Here the order of patches correspond to the parameters of the function
@@ -153,14 +167,46 @@ def cs3_client_insecure(
153167
return client
154168

155169

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+
156198
# All parameters are inferred by pytest from existing fixtures
157199
@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+
)
160204
return file
161205

162206

163207
@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+
)
166212
return user

0 commit comments

Comments
 (0)