17 lines
479 B
Python
17 lines
479 B
Python
import pytest
|
|
from fastapi import HTTPException
|
|
|
|
from app.validation import parse_positive_int_ids
|
|
|
|
|
|
def test_parse_alert_ids_accepts_positive_ints_and_decimal_strings():
|
|
assert parse_positive_int_ids([1, "2"]) == [1, 2]
|
|
|
|
|
|
@pytest.mark.parametrize("value", [["abc"], [0], [-1], [True], "1"])
|
|
def test_parse_alert_ids_rejects_malformed_values(value):
|
|
with pytest.raises(HTTPException) as exc:
|
|
parse_positive_int_ids(value)
|
|
|
|
assert exc.value.status_code == 400
|