mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 14:25:05 -02:30
RBAC copy/edit displays test refactor
This commit is contained in:
@@ -110,3 +110,27 @@ def test_jt_can_add_bad_data(user_unit):
|
||||
access = JobTemplateAccess(user_unit)
|
||||
assert not access.can_add({'asdf': 'asdf'})
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_capabilities_method():
|
||||
"""Unit test to verify that the user_capabilities method will defer
|
||||
to the appropriate sub-class methods of the access classes.
|
||||
Note that normal output is True/False, but a string is returned
|
||||
in these tests to establish uniqueness.
|
||||
"""
|
||||
|
||||
class FooAccess(BaseAccess):
|
||||
def can_change(self, obj, data):
|
||||
return 'bar'
|
||||
|
||||
def can_add(self, data):
|
||||
return 'foobar'
|
||||
|
||||
user = User(username='auser')
|
||||
foo_access = FooAccess(user)
|
||||
foo = object()
|
||||
foo_capabilities = foo_access.get_user_capabilities(foo, ['edit', 'copy'])
|
||||
assert foo_capabilities == {
|
||||
'edit': 'bar',
|
||||
'copy': 'foobar'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user