11"""Comprehensive end-to-end tests for ttmp32gme with real audio files."""
22
33import logging
4- import shutil
54import sqlite3
65import subprocess
7- import tempfile
86import time
97from pathlib import Path
108
119import pytest
12- from selenium .common .exceptions import NoSuchElementException , TimeoutException
10+ from selenium .common .exceptions import NoSuchElementException
1311from selenium .webdriver .common .by import By
1412from selenium .webdriver .remote .webelement import WebElement
1513from selenium .webdriver .support import expected_conditions as EC
@@ -55,7 +53,6 @@ def _open_library_element_for_editing(server_url, driver, element_number: int =
5553
5654def _create_gme (server_url , driver , element_number = 0 ):
5755 library_row = _open_library_element_for_editing (server_url , driver , element_number )
58- edit_button = library_row .find_element (By .CLASS_NAME , "edit-button" )
5956 create_button = library_row .find_element (By .CLASS_NAME , "make-gme" )
6057 create_button .click ()
6158 time .sleep (5 ) #
@@ -130,11 +127,12 @@ def test_upload_album_with_files(self, driver, clean_server):
130127 lambda d : album_name in d .find_element (By .TAG_NAME , "body" ).text
131128 )
132129 print ("DEBUG: Album found in library page" )
133- except :
130+ except Exception :
134131 # If timeout, print debug info
135132 body_text = driver .find_element (By .TAG_NAME , "body" ).text
136133 print (
137- f"DEBUG: Timeout waiting for album. Library page text: { body_text [:500 ]} "
134+ f"DEBUG: Timeout waiting for album. "
135+ f"Library page text: { body_text [:500 ]} "
138136 )
139137 raise
140138
@@ -318,11 +316,13 @@ def test_config_changes_persist(self, driver, base_config_with_album):
318316 EC .presence_of_element_located ((By .TAG_NAME , "body" ))
319317 )
320318
321- old_value = _get_database_value (
319+ # Use opposite of current value for testing
320+ # old_value is stored but not used in this simplified test
321+ _get_database_value (
322322 "SELECT value FROM config WHERE param ='audio_format'" ,
323323 db_path = server_info ["db_path" ],
324324 )[0 ]
325- new_value = "ogg" if old_value == "mp3" else "mp3"
325+ # new_value = "ogg" if old_value == "mp3" else "mp3"
326326
327327 # Change configuration options and save
328328 # Example: change audio format
@@ -349,8 +349,9 @@ def test_configuration_move_library(self, driver, base_config_with_album, tmp_pa
349349 _create_gme (server_info ["url" ], driver )
350350 time .sleep (2 ) # Wait for GME creation to complete
351351
352- # Get original library path and album info from database
353- old_library_path = _get_database_value (
352+ # Get album info from database
353+ # old_library_path is not used but kept for reference
354+ _get_database_value (
354355 "SELECT value FROM config WHERE param = 'library_path'" ,
355356 db_path = server_info ["db_path" ],
356357 )[0 ]
@@ -398,25 +399,29 @@ def test_configuration_move_library(self, driver, base_config_with_album, tmp_pa
398399 "SELECT value FROM config WHERE param = 'library_path'" ,
399400 db_path = server_info ["db_path" ],
400401 )[0 ]
401- assert new_config_path == str (
402- new_library_path
403- ), f"Library path not updated in config. Expected { new_library_path } , got { new_config_path } "
402+ assert new_config_path == str (new_library_path ), (
403+ f"Library path not updated in config. "
404+ f"Expected { new_library_path } , got { new_config_path } "
405+ )
404406
405407 # Verify album path updated in gme_library table
406- new_album_path_from_db = _get_database_value (
408+ # Store but don't use yet - may be needed for debugging
409+ _get_database_value (
407410 "SELECT path FROM gme_library WHERE oid = ?" ,
408411 params = (album_oid ,),
409412 db_path = server_info ["db_path" ],
410413 )[0 ]
411414
412- # The files are copied to the new library location with directory structure preserved
413- # The album directory name should be the same as before
415+ # The files are copied to the new library location with directory structure
416+ # preserved. The album directory name should be the same as before
414417 album_dir_name = Path (album_path ).name
415418 new_album_dir = new_library_path / album_dir_name
419+ # Check if files exist in new location
416420 if new_album_dir .exists ():
417- all_files = list (new_album_dir .glob ("*" ))
421+ list (new_album_dir .glob ("*" ))
418422
419- # The database path may not be correct due to a bug, but files should still be moved
423+ # The database path may not be correct due to a bug, but files should still
424+ # be moved
420425 assert (
421426 new_album_dir .exists ()
422427 ), f"Album directory not found at new location: { new_album_dir } "
@@ -434,10 +439,10 @@ def test_configuration_move_library(self, driver, base_config_with_album, tmp_pa
434439 # Note: We skip checking if the database path is perfectly correct as there may be a bug in change_library_path
435440 # The important thing is that files are moved and the application still works
436441
437- # Verify old location doesn't have the files anymore (they were copied, so original may still exist)
438- # Just log this for information
442+ # Verify old location doesn't have the files anymore (they were copied, so
443+ # original may still exist). Just log this for information
439444 if old_album_dir .exists ():
440- old_remaining_files = list (old_album_dir .glob ("*" ))
445+ list (old_album_dir .glob ("*" ))
441446
442447 # Test that GME can still be created after move
443448 # First update the database to point to the correct album directory
@@ -857,14 +862,17 @@ def test_print_album(self, driver, base_config_with_album):
857862 def _check_layout (
858863 album_element : WebElement ,
859864 layout : str = "list" ,
860- class_name : list [str ] = [
861- "cover" ,
862- "album-info" ,
863- "album-controls" ,
864- "tracks" ,
865- "general-controls" ,
866- ],
865+ class_name : list | None = None ,
867866 ):
867+ if class_name is None :
868+ class_name = [
869+ "cover" ,
870+ "album-info" ,
871+ "album-controls" ,
872+ "tracks" ,
873+ "general-controls" ,
874+ ]
875+
868876 if layout == "list" :
869877 # Default list layout: cover, album-info, album-controls and tracks visible
870878 should_be_hidden = [False , False , False , False , True ]
0 commit comments