This commit is contained in:
Kenneth Kehl
2025-09-10 10:34:56 -07:00
parent 861df96c8a
commit 4a3a1394b4
+18 -9
View File
@@ -16,14 +16,8 @@ from tests import create_service_authorization_header
from tests.app.db import create_api_key, create_notification from tests.app.db import create_api_key, create_notification
@given( @pytest.mark.usefixtures(
st.emails(), "client", "sample_service", "sample_template", "notify_db_session"
st.dictionaries(
keys=st.text(min_size=1, max_size=20),
values=st.text(min_size=0, max_size=100),
max_size=5,
),
st.one_of(st.none(), st.text(min_size=0, max_size=50)),
) )
def test_fuzz_send_email_notification( def test_fuzz_send_email_notification(
client, client,
@@ -34,6 +28,17 @@ def test_fuzz_send_email_notification(
personalisation, personalisation,
reference, reference,
): ):
@given(
st.emails(),
st.dictionaries(
keys=st.text(min_size=1, max_size=20),
values=st.text(min_size=0, max_size=100),
max_size=5,
),
st.one_of(st.none(), st.text(min_size=0, max_size=50)),
)
def inner(email_address, personalisation, reference):
template_id = str(sample_template.id) template_id = str(sample_template.id)
auth_header = { auth_header = {
"Authorization": "ApiKey-v1 {}".format(sample_service.api_keys[0].secret) "Authorization": "ApiKey-v1 {}".format(sample_service.api_keys[0].secret)
@@ -44,12 +49,16 @@ def test_fuzz_send_email_notification(
"personalisation": personalisation, "personalisation": personalisation,
"reference": reference, "reference": reference,
} }
response = client.post("/v2/notifications/email", json=payload, headers=auth_header) response = client.post(
"/v2/notifications/email", json=payload, headers=auth_header
)
assert response.status_code in ( assert response.status_code in (
201, 201,
400, 400,
), f"Unexpected status: {response.status_code}, body: {response.json}" ), f"Unexpected status: {response.status_code}, body: {response.json}"
inner()
@pytest.mark.parametrize("type", (NotificationType.EMAIL, NotificationType.SMS)) @pytest.mark.parametrize("type", (NotificationType.EMAIL, NotificationType.SMS))
def test_get_notification_by_id( def test_get_notification_by_id(