From b70450fb5517fff09a4f452f22b3318d646baddf Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 15 Sep 2025 18:49:34 -0700 Subject: [PATCH] ugh --- app/organization/rest.py | 8 +++++--- tests/app/organization/test_rest.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/organization/rest.py b/app/organization/rest.py index b335ef910..297108dfd 100644 --- a/app/organization/rest.py +++ b/app/organization/rest.py @@ -94,11 +94,13 @@ def create_organization(): validate(data, post_create_organization_schema) organization = Organization(**data) dao_create_organization(organization) + return jsonify(organization.serialize()), 201 except Exception: current_app.logger.exception("Validation error creating organization") - return jsonify({"Error": "Validation error"}), 400 - - return jsonify(organization.serialize()), 201 + return ( + jsonify(result="error", message="Validation error creating organization"), + 400, + ) @organization_blueprint.route("/", methods=["POST"]) diff --git a/tests/app/organization/test_rest.py b/tests/app/organization/test_rest.py index c79d31022..b96282651 100644 --- a/tests/app/organization/test_rest.py +++ b/tests/app/organization/test_rest.py @@ -242,9 +242,7 @@ seen = set() @pytest.mark.usefixtures( "admin_request", ) -def test_fuzz_create_org_with_edge_cases( - admin_request, -): +def test_fuzz_create_org_with_edge_cases(admin_request, notify_db_session): # We want to avoid replays, because once an organization is created, replaying will result in a # duplicate error on our side. Unfortunately, to avoid replays in hypothesis is hard! @@ -307,6 +305,10 @@ def test_fuzz_create_org_with_edge_cases( else: assert response.status_code in (400, 422) assert len(_get_organizations()) == initial_count + rows = notify_db_session.query(Organization).filter_by(name=f"{name}").all() + for row in rows: + notify_db_session.delete(row) + notify_db_session.commit() except AssertionError: if is_valid: pytest.fail(f"Expected success but got error. Data: {data} {response}")