Skip to content

Commit a698cf0

Browse files
committed
Fix reference to child model failing tests
1 parent 3f4e164 commit a698cf0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ansible_base/rbac/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def validate_codename_for_model(codename: str, model: Union[Model, Type[Model],
228228
return name
229229

230230
for rel, child_cls in permission_registry.get_child_models(model):
231-
child_ct = permission_registry.content_type_model.objects.get_for_model(model)
231+
child_ct = permission_registry.content_type_model.objects.get_for_model(child_cls)
232232
if name in codenames_for_content_type(child_ct):
233233
return name
234234
raise RuntimeError(f'The permission {name} is not valid for model {model._meta.model_name}')

test_app/tests/rbac/test_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_no_change_permission_without_view(enabled):
144144

145145

146146
@pytest.mark.django_db
147-
@pytest.mark.parametrize('cls', permission_registry.all_registered_models)
147+
@pytest.mark.parametrize('cls', sorted(permission_registry.all_registered_models, key=lambda cls: cls._meta.model_name))
148148
def test_db_model_validators_match(cls):
149149
"This is a code transition test, making sure new DB-backed methods match model-backed methods"
150150

0 commit comments

Comments
 (0)