From 41bf0e16faf8256943f3064b0a855cd539e2665e Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sat, 21 Nov 2026 17:19:15 -0500 Subject: [PATCH] test(CR-12): add [min-1, min, max, max+1] boundary tests for schemas and lookup IDs - Parametrize length boundaries for ZoomCredentials (account_id, client_id, client_secret) - Parametrize [min-1, min, max, max+1] boundaries for AppointmentCreateRequest (client_name, duration_minutes, amount_usd) - Parametrize lookup_id length boundaries (blank, len 64 -> 404, len 65 -> 400) --- tests/test_app.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/test_app.py b/tests/test_app.py index a16b026..5ceb61d 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -699,3 +699,86 @@ def test_delete_confirmed_calls_zoom_delete(client, monkeypatch): d_resp = test_client.delete(f"/api/appointments/{sid}", json={"credentials": SAMPLE_CREDS}) assert d_resp.status_code == 200 assert delete_calls == ["https://api.zoom.us/v2/meetings/44556677"] + + +@pytest.mark.parametrize( + ("field", "length", "expected_status"), + [ + ("account_id", 3, 422), + ("account_id", 4, 200), + ("account_id", 128, 200), + ("account_id", 129, 422), + ("client_id", 3, 422), + ("client_id", 4, 200), + ("client_id", 128, 200), + ("client_id", 129, 422), + ("client_secret", 3, 422), + ("client_secret", 4, 200), + ("client_secret", 256, 200), + ("client_secret", 257, 422), + ], +) +def test_zoom_credentials_length_boundaries(client, monkeypatch, field, length, expected_status): + test_client, _ = client + monkeypatch.setattr( + zoom.requests, + "post", + lambda url, **kwargs: FakeResponse(200, {"access_token": "mock_token"}), + ) + payload = dict(SAMPLE_CREDS) + payload[field] = "x" * length + resp = test_client.post("/api/zoom/verify-credentials", json=payload) + assert resp.status_code == expected_status + + +@pytest.mark.parametrize( + ("overrides", "expected_status"), + [ + ({"client_name": "A"}, 422), + ({"client_name": "AB"}, 201), + ({"client_name": "A" * 120}, 201), + ({"client_name": "A" * 121}, 422), + ({"duration_minutes": 14}, 422), + ({"duration_minutes": 15}, 201), + ({"duration_minutes": 240}, 201), + ({"duration_minutes": 241}, 422), + ({"amount_usd": 0}, 422), + ({"amount_usd": 0.01}, 201), + ({"amount_usd": 10000}, 201), + ({"amount_usd": 10000.01}, 422), + ], +) +def test_appointment_create_request_boundaries(client, monkeypatch, overrides, expected_status): + test_client, _ = client + monkeypatch.setattr( + zoom.requests, + "post", + lambda url, **kwargs: FakeResponse(200, {"access_token": "mock_token"}), + ) + monkeypatch.setattr( + zoom.requests, + "get", + lambda url, **kwargs: FakeResponse(200, {"meetings": []}), + ) + payload = { + "credentials": SAMPLE_CREDS, + "client_name": "MarĂ­a Perez", + "start_time_local": "2026-11-25T15:00", + **overrides, + } + resp = test_client.post("/api/appointments", json=payload) + assert resp.status_code == expected_status + + +@pytest.mark.parametrize( + ("lookup_id", "expected_status"), + [ + (" ", 400), + ("a" * 64, 404), + ("a" * 65, 400), + ], +) +def test_get_appointment_lookup_id_length_boundaries(client, lookup_id, expected_status): + test_client, _ = client + resp = test_client.get(f"/api/appointments/{lookup_id}") + assert resp.status_code == expected_status