mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
ugh
This commit is contained in:
@@ -94,11 +94,13 @@ def create_organization():
|
|||||||
validate(data, post_create_organization_schema)
|
validate(data, post_create_organization_schema)
|
||||||
organization = Organization(**data)
|
organization = Organization(**data)
|
||||||
dao_create_organization(organization)
|
dao_create_organization(organization)
|
||||||
|
return jsonify(organization.serialize()), 201
|
||||||
except Exception:
|
except Exception:
|
||||||
current_app.logger.exception("Validation error creating organization")
|
current_app.logger.exception("Validation error creating organization")
|
||||||
return jsonify({"Error": "Validation error"}), 400
|
return (
|
||||||
|
jsonify(result="error", message="Validation error creating organization"),
|
||||||
return jsonify(organization.serialize()), 201
|
400,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@organization_blueprint.route("/<uuid:organization_id>", methods=["POST"])
|
@organization_blueprint.route("/<uuid:organization_id>", methods=["POST"])
|
||||||
|
|||||||
@@ -242,9 +242,7 @@ seen = set()
|
|||||||
@pytest.mark.usefixtures(
|
@pytest.mark.usefixtures(
|
||||||
"admin_request",
|
"admin_request",
|
||||||
)
|
)
|
||||||
def test_fuzz_create_org_with_edge_cases(
|
def test_fuzz_create_org_with_edge_cases(admin_request, notify_db_session):
|
||||||
admin_request,
|
|
||||||
):
|
|
||||||
|
|
||||||
# We want to avoid replays, because once an organization is created, replaying will result in a
|
# 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!
|
# 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:
|
else:
|
||||||
assert response.status_code in (400, 422)
|
assert response.status_code in (400, 422)
|
||||||
assert len(_get_organizations()) == initial_count
|
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:
|
except AssertionError:
|
||||||
if is_valid:
|
if is_valid:
|
||||||
pytest.fail(f"Expected success but got error. Data: {data} {response}")
|
pytest.fail(f"Expected success but got error. Data: {data} {response}")
|
||||||
|
|||||||
Reference in New Issue
Block a user