import os from unittest.mock import patch import config from pendulum import DateTime, Time, Timezone @patch.dict( os.environ, { "CLUB_URL": "club.url", "COURT_IDS": "7,8,10", "CLUB_ID": "666", "BOOKING_OPEN_DAYS_BEFORE": "5", "BOOKING_OPENING_TIME": "18:37", }, clear=True, ) def test_get_club(): club = config.get_club() assert club.url == "club.url" assert club.courts_ids == [7, 8, 10] assert club.id == "666" assert club.booking_open_days_before == 5 assert club.booking_opening_time == Time(hour=18, minute=37) @patch.dict( os.environ, { "SPORT_ID": "666", "DATE_TIME": "2024-02-03T22:38:45Z", }, clear=True, ) def test_get_booking_filter(): booking_filter = config.get_booking_filter() assert booking_filter.sport_id == 666 assert booking_filter.date == DateTime( year=2024, month=2, day=3, hour=23, minute=38, second=45, tzinfo=Timezone("Europe/Paris"), ) @patch.dict( os.environ, { "LOGIN": "login@user.tld", "PASSWORD": "gloups", }, clear=True, ) def test_get_available_user(): user = config.get_user() assert user.login == "login@user.tld" assert user.password == "gloups" @patch.dict( os.environ, {"AVAILABLE_USERS_CREDENTIALS": "login@user.tld:gloups,other@user.tld:patatras"}, clear=True, ) def test_user(): users = config.get_available_users() assert users[0].login == "login@user.tld" assert users[0].password == "gloups" assert users[1].login == "other@user.tld" assert users[1].password == "patatras"