fix: check none type in _check_response_type_and_not_empty

This commit is contained in:
dettlaff 2024-12-11 11:51:22 +04:00
parent c5ae43aab3
commit 3bff37cb79
3 changed files with 10 additions and 4 deletions

View file

@ -158,8 +158,8 @@ def update_user(
)
def get_user_by_username(username: str) -> Optional[UserDataUser]:
user: UserDataUser | None = ACTIVE_USERS_PROVIDER.get_user_by_username(
def get_user_by_username(username: str) -> UserDataUser:
user = ACTIVE_USERS_PROVIDER.get_user_by_username(
username=username
)

View file

@ -10,6 +10,7 @@ from selfprivacy_api.graphql.common_types.user import (
get_users,
)
from selfprivacy_api.graphql import IsAuthenticated
# from selfprivacy_api.repositories.users.exceptions import UserNotFound
@strawberry.type
@ -17,7 +18,11 @@ class Users:
@strawberry.field(permission_classes=[IsAuthenticated])
def get_user(self, username: str) -> typing.Optional[User]:
"""Get users"""
# try:
return get_user_by_username(username)
# except UserNotFound:
# return None
all_users: typing.List[User] = strawberry.field(
permission_classes=[IsAuthenticated], resolver=get_users

View file

@ -118,11 +118,12 @@ class KanidmUserRepository(AbstractUserRepository):
logging.info(response_data)
if response_data is None:
raise KanidmReturnEmptyResponse
if data_type == "list":
if not isinstance(response_data, list):
raise KanidmReturnUnknownResponseType(response_data=response_data)
if not response_data:
raise KanidmReturnEmptyResponse
elif data_type == "dict":
if not isinstance(response_data, dict):