This commit is contained in:
Kenneth Kehl
2025-09-15 11:31:51 -07:00
parent 3984d41fa4
commit 21c388364c

View File

@@ -241,7 +241,6 @@ def test_post_create_organization_works(admin_request, sample_organization):
def test_fuzz_create_org_with_edge_cases( def test_fuzz_create_org_with_edge_cases(
admin_request, admin_request,
): ):
list_of_names = []
@settings(max_examples=10) @settings(max_examples=10)
@given( @given(
@@ -262,6 +261,9 @@ def test_fuzz_create_org_with_edge_cases(
existing = _get_organizations() existing = _get_organizations()
initial_count = len(existing) initial_count = len(existing)
# We are doing this so replays don't generate inconsistent results,
# resulting in a FlakyFailure
name += str(uuid.uuid4())
data = { data = {
"name": name, "name": name,
"active": active, "active": active,
@@ -275,26 +277,25 @@ def test_fuzz_create_org_with_edge_cases(
and isinstance(active, bool) and isinstance(active, bool)
} }
expected_status = 201 if is_valid else 400 expected_status = 201 if is_valid else 400
if name not in list_of_names: try:
try: response = admin_request.post(
response = admin_request.post( "organization.create_organization",
"organization.create_organization", _data=data,
_data=data, _expected_status=expected_status,
_expected_status=expected_status, )
) assert response == "FOO"
list_of_names.append(name) if (
if ( name
name and organization_type is not None
and organization_type is not None and isinstance(organization_type, OrganizationType)
and isinstance(organization_type, OrganizationType) ):
): assert response.status_code == 201
assert response.status_code == 201 assert len(_get_organizations()) == initial_count + 1
assert len(_get_organizations()) == initial_count + 1 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 except Exception as e:
except Exception as e: pytest.fail(f"Unexpected error durring fuzz test: {e}")
pytest.fail(f"Unexpected error durring fuzz test: {e}")
inner() inner()