import logging import random import allure from ui_automation_framework.utils import AppConfig from ui_automation_framework.utils import logger as cl from app.src.api.constants import APPLE, SPOTIFY log = cl.Logger(logging.DEBUG) @allure.step("Get random playlist") def get_random_playlist(vendor): vendor_playlists = {APPLE: "playlists_apple", SPOTIFY: "playlists_spotify"}[vendor] all_playlists = list(AppConfig.get(vendor_playlists).items()) playlist_id, playlist_name = random.choice(all_playlists) log.info(f"Result of {get_random_playlist.__name__} function:" f"\nPlaylist ID: {playlist_id}" f"\nPlaylist name: {playlist_name}") return playlist_id, playlist_name @allure.step("Get random Hot Hits Spotify playlist") def get_random_hot_hits_spotify_playlist(): hh_playlists = "hot_hits_playlists_spotify" all_playlists = list(AppConfig.get(hh_playlists).items()) playlist_id, playlist_name = random.choice(all_playlists) log.info(f"Result of {get_random_playlist.__name__} function:" f"\nPlaylist ID: {playlist_id}" f"\nPlaylist name: {playlist_name}") return playlist_id, playlist_name