From e68e77a821869b2c6e6c54b25e4e22fca71c8ecc Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 4 May 2026 22:30:03 +0200 Subject: [PATCH] test: parametrize event-types und tighten validation-error assertion --- tests/test_webhook.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 9ef9212..976b92a 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -1,17 +1,26 @@ import pytest from fastapi import HTTPException +from pydantic import ValidationError from app.webhook.models import NextcloudEvent, EventType from app.webhook.auth import verify_secret -def test_event_parses_created(): - evt = NextcloudEvent(event_type="created", file_path="a/b.pdf", file_name="b.pdf") - assert evt.event_type == EventType.CREATED +@pytest.mark.parametrize( + "raw,expected", + [ + ("created", EventType.CREATED), + ("updated", EventType.UPDATED), + ("deleted", EventType.DELETED), + ], +) +def test_event_parses_valid_types(raw, expected): + evt = NextcloudEvent(event_type=raw, file_path="a/b.pdf", file_name="b.pdf") + assert evt.event_type == expected def test_event_invalid_type_raises(): - with pytest.raises(Exception): + with pytest.raises(ValidationError): NextcloudEvent(event_type="exploded", file_path="a", file_name="a")