Skip to content

Commit 3c24e1e

Browse files
committed
merge api missing element tests
1 parent dd782ef commit 3c24e1e

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

tests/test_api_routes.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,33 @@ def test_validate_by_id_success(client):
3131
mock_queue.assert_called_once_with("test_bucket", "crate-123", "base_path", "default", "https://webhook.example.com")
3232

3333

34-
def test_validate_by_id_fails_missing_crate_id(client):
35-
payload = {
36-
"minio_bucket": "test_bucket",
37-
"root_path": "base_path",
38-
"webhook_url": "https://webhook.example.com",
39-
"profile_name": "default"
40-
}
41-
42-
response = client.post("/v1/ro_crates//validation", json=payload)
43-
44-
assert response.status_code == 404
45-
46-
47-
def test_validate_by_id_fails_missing_minio_bucket(client):
48-
crate_id = "crate-123"
49-
payload = {
50-
"root_path": "base_path",
51-
"webhook_url": "https://webhook.example.com",
52-
"profile_name": "default"
53-
}
54-
34+
@pytest.mark.parametrize(
35+
"crate_id, payload, status_code",
36+
[
37+
(
38+
"", {
39+
"minio_bucket": "test_bucket",
40+
"root_path": "base_path",
41+
"webhook_url": "https://webhook.example.com",
42+
"profile_name": "default"
43+
}, 404
44+
),
45+
(
46+
"crate-123", {
47+
"root_path": "base_path",
48+
"webhook_url": "https://webhook.example.com",
49+
"profile_name": "default"
50+
}, 422
51+
),
52+
],
53+
ids=[
54+
"missing_crate_id_returns_404",
55+
"missing_minio_bucket_returns_422"
56+
]
57+
)
58+
def test_validate_fails_missing_elements(client, crate_id, payload, status_code):
5559
response = client.post(f"/v1/ro_crates/{crate_id}/validation", json=payload)
56-
57-
assert response.status_code == 422
60+
assert response.status_code == status_code
5861

5962

6063
def test_validate_by_id_missing_root_path_and_profile_name_and_webhook_url(client):

0 commit comments

Comments
 (0)