Skip to content

Commit 8a3ff74

Browse files
Fixed type lint error
1 parent 0679810 commit 8a3ff74

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tests/test_role.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@
88
@pytest.fixture
99
def admin_user(session: Session, test_user: User, test_organization):
1010
"""Create an admin user with CREATE_ROLE permission"""
11-
admin_role = Role(
11+
admin_role: Role = Role(
1212
name="Admin",
1313
organization_id=test_organization.id
1414
)
15-
create_role_permission = session.exec(
15+
16+
create_role_permission: Permission | None = session.exec(
1617
select(Permission).where(Permission.name == ValidPermissions.CREATE_ROLE)
1718
).first()
19+
20+
if create_role_permission is None:
21+
raise ValueError("Error during test setup: CREATE_ROLE permission not found")
22+
1823
admin_role.permissions.append(create_role_permission)
1924
session.add(admin_role)
20-
25+
2126
test_user.roles.append(admin_role)
2227
session.commit()
28+
2329
return test_user
2430

2531

@@ -34,17 +40,17 @@ def test_create_role_success(auth_client, admin_user, test_organization, session
3440
},
3541
follow_redirects=False
3642
)
37-
43+
3844
assert response.status_code == 303
39-
45+
4046
# Verify role was created in database
4147
created_role = session.exec(
4248
select(Role).where(
4349
Role.name == "Test Role",
4450
Role.organization_id == test_organization.id
4551
)
4652
).first()
47-
53+
4854
assert created_role is not None
4955
assert created_role.name == "Test Role"
5056
assert len(created_role.permissions) == 1
@@ -62,7 +68,7 @@ def test_create_role_unauthorized(auth_client, test_user, test_organization):
6268
},
6369
follow_redirects=False
6470
)
65-
71+
6672
assert response.status_code == 403
6773

6874

@@ -75,7 +81,7 @@ def test_create_duplicate_role(auth_client, admin_user, test_organization, sessi
7581
)
7682
session.add(existing_role)
7783
session.commit()
78-
84+
7985
# Attempt to create role with same name
8086
response = auth_client.post(
8187
"/roles/create",
@@ -86,7 +92,7 @@ def test_create_duplicate_role(auth_client, admin_user, test_organization, sessi
8692
},
8793
follow_redirects=False
8894
)
89-
95+
9096
assert response.status_code == 400
9197

9298

@@ -101,5 +107,5 @@ def test_create_role_unauthenticated(unauth_client, test_organization):
101107
},
102108
follow_redirects=False
103109
)
104-
110+
105111
assert response.status_code == 303

0 commit comments

Comments
 (0)