"""Test cases for MusicManager"""
from src.music_manager_micro.music_manager import MusicManager as MM

LIBRARY_NAME = '###TESTABC###'
music_manager = MM(LIBRARY_NAME, "tests/multi_sample")
music_manager.reset_library()
music_manager.DEBUG = False


def test_getfiles():
    '''test file search'''
    root_dir = 'tests/multi_sample'
    l = music_manager._get_files_from_folder(root_dir)
    assert len(l) == 2
    assert l[0] == 'tests/multi_sample/2.mp3'
    assert l[1] == 'tests/multi_sample/1.mp3'

# Tests a music file can generate a valid string representation


def test_build_entry():
    '''test single entry formatting'''
    root_dir = 'tests/multi_sample'
    l = music_manager._get_files_from_folder(root_dir)
    e = music_manager._build_entry(l[0])
    assert e[0] == 1690570765.6394708
    assert e[1] == 'tests/multi_sample/2.mp3'

# Tests that a root directory can generate a list of valid strings


def test_build_list():
    '''full build of a directory'''
    root_dir = 'tests/multi_sample'
    e = music_manager._build_list(root_dir)
    assert e[0][0] == 1690570765.6394708
    assert e[1][1] == 'tests/multi_sample/1.mp3'


def test_empty_folder():
    '''no files present'''
    root_dir = 'tests/empty_folder'
    e = music_manager._build_list(root_dir)
    assert len(e) == 0


def test_execute():
    '''test full process'''
    l = music_manager.execute()
    assert len(l) == 2
    l = music_manager.get_list()
    assert len(l) == 2


def test_get_list():
    '''test returning values without running'''
    l = music_manager.get_list()
    assert len(l) == 2
