Complete the code to check if a user has admin rights.
if user.role == [1]: access_granted = True
The code checks if the user's role is exactly "admin" to grant access.
Complete the code to deny access if the user is not authorized.
if not user.is_authorized(): [1] = False
Setting access_granted to False denies access when the user is not authorized.
Fix the error in the authorization check to correctly verify user permissions.
if "edit" [1] user.permissions: allow_edit = True
Using in checks if "edit" is among the user's permissions.
Fill both blanks to create a test that asserts unauthorized users cannot access admin pages.
def test_admin_access(user): assert user.role [1] "admin" assert access_to_admin_page(user) [2] False
The test asserts the user role is not 'admin' and that access is denied (False).
Fill all three blanks to create a dictionary comprehension that maps users to their access status based on role.
access_map = {user.name: True if user.role [1] "admin" [2] True [3] False for user in users}The comprehension assigns True if the user's role is 'admin', else False.