Skip to content

Commit 0d4c307

Browse files
committed
update process validation failure tests
1 parent 1629663 commit 0d4c307

1 file changed

Lines changed: 44 additions & 11 deletions

File tree

tests/test_validation_tasks.py

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,50 @@ def test_process_validation(
112112

113113

114114
@pytest.mark.parametrize(
115-
"crate_id, os_path_exists, os_path_isfile, os_path_isdir, return_fetch, "
116-
+ "webhook, profile, return_validate, validate_side_effect, fetch_side_effect",
115+
"minio_config, crate_id, os_path_exists, os_path_isfile, os_path_isdir, return_fetch, "
116+
+ "webhook, profile, return_validate, validate_side_effect, fetch_side_effect, minio_client",
117117
[
118-
("crate123", True, True, False, "/tmp/crate.zip",
119-
"https://example.com/hook", "profileA", "Validation failed", None, None),
120-
("crate123", True, True, False, "/tmp/crate.zip",
121-
"https://example.com/hook", "profileA", None, Exception("Unexpected error"), None),
122-
("crate123", False, False, False, None,
123-
"https://example.com/hook", "profileA", None, None, Exception("MinIO fetch failed")),
118+
(
119+
{
120+
"endpoint": "localhost:9000",
121+
"accesskey": "admin",
122+
"secret": "password123",
123+
"ssl": False,
124+
"bucket": "test_bucket"
125+
},
126+
"crate123", True, True, False, "/tmp/crate.zip",
127+
"https://example.com/hook", "profileA", "Validation failed", None, None,
128+
"minio_client"
129+
),
130+
(
131+
{
132+
"endpoint": "localhost:9000",
133+
"accesskey": "admin",
134+
"secret": "password123",
135+
"ssl": False,
136+
"bucket": "test_bucket"
137+
},
138+
"crate123", True, True, False, "/tmp/crate.zip",
139+
"https://example.com/hook", "profileA", None, Exception("Unexpected error"), None,
140+
"minio_client"
141+
),
142+
(
143+
{
144+
"endpoint": "localhost:9000",
145+
"accesskey": "admin",
146+
"secret": "password123",
147+
"ssl": False,
148+
"bucket": "test_bucket"
149+
},
150+
"crate123", False, False, False, None,
151+
"https://example.com/hook", "profileA", None, None, Exception("MinIO fetch failed"),
152+
"minio_client"
153+
),
124154
],
125155
ids=["validation_fails_with_message", "validation_fails_with_validation_exception",
126156
"validation_fails_with_fetch_exception"]
127157
)
158+
@mock.patch("app.tasks.validation_tasks.get_minio_client")
128159
@mock.patch("app.tasks.validation_tasks.shutil.rmtree")
129160
@mock.patch("app.tasks.validation_tasks.os.remove")
130161
@mock.patch("app.tasks.validation_tasks.os.path.exists")
@@ -144,13 +175,15 @@ def test_process_validation_failure(
144175
mock_exists,
145176
mock_remove,
146177
mock_rmtree,
147-
crate_id: str, os_path_exists: bool, os_path_isfile: bool, os_path_isdir: bool,
178+
mock_client,
179+
minio_config: dict, crate_id: str, os_path_exists: bool, os_path_isfile: bool, os_path_isdir: bool,
148180
return_fetch: str, webhook: str, profile: str, return_validate: str,
149-
validate_side_effect: Exception, fetch_side_effect: Exception
181+
validate_side_effect: Exception, fetch_side_effect: Exception, minio_client: str
150182
):
151183
mock_exists.return_value = os_path_exists
152184
mock_isfile.return_value = os_path_isfile
153185
mock_isdir.return_value = os_path_isdir
186+
mock_client.return_value = minio_client
154187

155188
if fetch_side_effect is None:
156189
mock_fetch.return_value = return_fetch
@@ -162,7 +195,7 @@ def test_process_validation_failure(
162195
else:
163196
mock_validate.side_effect = validate_side_effect
164197

165-
process_validation_task_by_id("test_bucket", crate_id, "", profile, webhook)
198+
process_validation_task_by_id(minio_config, crate_id, "", profile, webhook)
166199

167200
if fetch_side_effect is None:
168201
mock_validate.assert_called_once_with(return_fetch, profile)

0 commit comments

Comments
 (0)