test: parametrize event-types und tighten validation-error assertion
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user