Skip to content

Commit 235f279

Browse files
committed
Auto generate scenario names
1 parent 0969122 commit 235f279

File tree

1 file changed

+5
-80
lines changed

1 file changed

+5
-80
lines changed

test_app/tests/rbac/test_claims.py

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,7 @@ def shared_test_data(self, db):
248248
def claims_scenario(self, shared_test_data):
249249
return ClaimsScenario(shared_test_data)
250250

251-
@pytest.mark.parametrize(
252-
"scenario_name",
253-
[
254-
'no_permissions',
255-
'first_org_only',
256-
'odds_org_admin',
257-
'evens_org_admin',
258-
'first_three_teams',
259-
'platform_auditor_only',
260-
'mixed_small',
261-
'mixed_large',
262-
'all_org_admin',
263-
'scattered_permissions',
264-
'teams_no_orgs',
265-
],
266-
)
251+
@pytest.mark.parametrize("scenario_name", list(PermissionScenarios.get_scenario_definitions().keys()))
267252
def test_claims_scenarios(self, claims_scenario, scenario_name):
268253
"""Test various permission scenarios produce correct claims"""
269254
user = get_user_model().objects.create(username=f'test_user_{scenario_name}')
@@ -279,22 +264,7 @@ def test_claims_scenarios(self, claims_scenario, scenario_name):
279264

280265
assert actual_claims == expected_claims
281266

282-
@pytest.mark.parametrize(
283-
"scenario_name",
284-
[
285-
'no_permissions',
286-
'first_org_only',
287-
'odds_org_admin',
288-
'evens_org_admin',
289-
'first_three_teams',
290-
'platform_auditor_only',
291-
'mixed_small',
292-
'mixed_large',
293-
'all_org_admin',
294-
'scattered_permissions',
295-
'teams_no_orgs',
296-
],
297-
)
267+
@pytest.mark.parametrize("scenario_name", list(PermissionScenarios.get_scenario_definitions().keys()))
298268
def test_hashable_claims_scenarios(self, claims_scenario, scenario_name):
299269
"""Test various permission scenarios produce correct hashable claims"""
300270
user = get_user_model().objects.create(username=f'test_hashable_user_{scenario_name}')
@@ -311,22 +281,7 @@ def test_hashable_claims_scenarios(self, claims_scenario, scenario_name):
311281

312282
assert actual_hashable_claims == expected_hashable_claims
313283

314-
@pytest.mark.parametrize(
315-
"scenario_name",
316-
[
317-
'no_permissions',
318-
'first_org_only',
319-
'odds_org_admin',
320-
'evens_org_admin',
321-
'first_three_teams',
322-
'platform_auditor_only',
323-
'mixed_small',
324-
'mixed_large',
325-
'all_org_admin',
326-
'scattered_permissions',
327-
'teams_no_orgs',
328-
],
329-
)
284+
@pytest.mark.parametrize("scenario_name", list(PermissionScenarios.get_scenario_definitions().keys()))
330285
def test_identical_permissions_same_hash(self, claims_scenario, scenario_name):
331286
"""Test that two users with identical permissions produce the same hash"""
332287
# Create two different users
@@ -356,22 +311,7 @@ def test_identical_permissions_same_hash(self, claims_scenario, scenario_name):
356311
assert len(user1_hash) == 64
357312
assert all(c in '0123456789abcdef' for c in user1_hash)
358313

359-
@pytest.mark.parametrize(
360-
"scenario_name",
361-
[
362-
'no_permissions',
363-
'first_org_only',
364-
'odds_org_admin',
365-
'evens_org_admin',
366-
'first_three_teams',
367-
'platform_auditor_only',
368-
'mixed_small',
369-
'mixed_large',
370-
'all_org_admin',
371-
'scattered_permissions',
372-
'teams_no_orgs',
373-
],
374-
)
314+
@pytest.mark.parametrize("scenario_name", list(PermissionScenarios.get_scenario_definitions().keys()))
375315
def test_serialize_and_save_claims(self, claims_scenario, scenario_name):
376316
"""Test that serialized claims from first user can be saved to second user"""
377317
# Create two different users
@@ -404,22 +344,7 @@ def test_serialize_and_save_claims(self, claims_scenario, scenario_name):
404344
# Verify hashes are identical
405345
assert user1_hash == user2_hash
406346

407-
@pytest.mark.parametrize(
408-
"scenario_name",
409-
[
410-
'no_permissions',
411-
'first_org_only',
412-
'odds_org_admin',
413-
'evens_org_admin',
414-
'first_three_teams',
415-
'platform_auditor_only',
416-
'mixed_small',
417-
'mixed_large',
418-
'all_org_admin',
419-
'scattered_permissions',
420-
'teams_no_orgs',
421-
],
422-
)
347+
@pytest.mark.parametrize("scenario_name", list(PermissionScenarios.get_scenario_definitions().keys()))
423348
def test_rebuild_single_user(self, claims_scenario, scenario_name):
424349
"""Get claims hash, then just delete everything and save_user_claims should build it back up"""
425350
user = get_user_model().objects.create(username=f'test_hash_user1_{scenario_name}')

0 commit comments

Comments
 (0)