added available users in config

This commit is contained in:
Stanislas Jouffroy 2024-02-20 18:47:11 +01:00
parent 52b962c709
commit d0a0072b6d
2 changed files with 93 additions and 0 deletions

View file

@ -64,6 +64,25 @@ def get_user() -> User:
return User(login=login, password=password)
def get_available_users() -> list[User]:
"""
Read the environment variables to get all the available users in order
to increase the chance of having a user with a free slot for a booking
:return: the list of all users that can book a court
"""
available_users_credentials = os.environ.get("AVAILABLE_USERS_CREDENTIALS")
available_users = [
credential for credential in available_users_credentials.split(",")
]
users = []
for user in available_users:
login, password = user.split(":")
users.append(User(login=login, password=password))
return users
def get_post_headers(platform_id: str) -> dict:
"""
Get the headers for the POST endpoint related to a specific booking platform