diff --git a/tests/app/organization/test_rest.py b/tests/app/organization/test_rest.py index a0d5ef50d..bf20be588 100644 --- a/tests/app/organization/test_rest.py +++ b/tests/app/organization/test_rest.py @@ -3,6 +3,8 @@ from unittest.mock import Mock import pytest from freezegun import freeze_time +from hypothesis import HealthCheck, given, settings +from hypothesis import strategies as st from sqlalchemy import select from sqlalchemy.exc import SQLAlchemyError @@ -275,6 +277,28 @@ def test_post_create_organization_with_missing_data_gives_validation_error( assert response["errors"][0]["message"] == expected_error +@settings(suppress_health_check=[HealthCheck.function_scoped_fixture]) +@given( + fuzzed_name=st.one_of(st.none(), st.text(min_size=1, max_size=2000)), + fuzzed_active=st.one_of(st.none(), st.booleans()), + fuzzed_organization_type=st.one_of(st.none, st.sample_from(list(OrganizationType))), +) +def test_fuzz_post_create_organization_with_missing_data_gives_validation_error( + admin_request, fuzzed_name, fuzzed_active, fuzzed_organization_type +): + data = { + "name": fuzzed_name, + "active": fuzzed_active, + "organization_type": fuzzed_organization_type, + } + response = admin_request.post( + "organization.create_organization", _data=data, _expected_status=400 + ) + + assert len(response["errors"]) == 1 + assert response["errors"][0]["error"] == "ValidationError" + + def test_post_update_organization_updates_fields( admin_request, notify_db_session,