mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-05 16:48:31 -04:00
add another test
This commit is contained in:
@@ -6,6 +6,8 @@ from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
from hypothesis import given
|
||||
from hypothesis import strategies as st
|
||||
from sqlalchemy import select
|
||||
|
||||
from app import db
|
||||
@@ -297,6 +299,33 @@ def test_should_be_error_if_service_does_not_exist_on_update(client, fake_uuid):
|
||||
assert json_resp["message"] == "No result found"
|
||||
|
||||
|
||||
@given(
|
||||
fuzzed_service_id=st.uuids(),
|
||||
fuzzed_template_id=st.uuids(),
|
||||
fuzzed_template_name=st.text(min_size=1, max_size=100),
|
||||
)
|
||||
def test_fuzz_should_be_error_if_service_does_not_exist_on_update(
|
||||
client, fuzzed_service_id, fuzzed_template_id, fuzzed_template_name
|
||||
):
|
||||
"""
|
||||
Hypothesis-based fuzz test to ensure that when updating a template
|
||||
for a non-existent service, the API returns a 404 with the correct error message
|
||||
"""
|
||||
data = {"name": fuzzed_template_name}
|
||||
data = json.dumps(data)
|
||||
auth_header = create_admin_authorization_header()
|
||||
response = client.post(
|
||||
f"/service/{fuzzed_service_id}/tempalte/{fuzzed_template_id}",
|
||||
headers=[("Content-Type", "application/json"), auth_header],
|
||||
data=data,
|
||||
)
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert response.status_code == 404
|
||||
assert json_resp["result"] == "error"
|
||||
assert json_resp["message"] == "No result found"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("template_type", [TemplateType.EMAIL])
|
||||
def test_must_have_a_subject_on_an_email_template(
|
||||
client, sample_user, sample_service, template_type
|
||||
|
||||
Reference in New Issue
Block a user