From d2c3e8ab8f1dcaec2b8be7ff9d1fb6c0df2d5296 Mon Sep 17 00:00:00 2001 From: Warry Date: Sat, 29 Nov 2025 12:10:06 +0100 Subject: feat(hover): add track details preview on hover + fix all ruff violations Implement comprehensive track information display on hover and resolve all code quality issues to achieve complete ruff compliance. MAJOR FEATURES: - Track details preview on hover with rich metadata display - Async BPM fetching with loading indicator - Enhanced metadata utilities with fuzzy matching - TIDAL API extras integration FILES MODIFIED: 15+ files (core, UI, tests, docs) RUFF COMPLIANCE: 0 errors (89+ violations resolved) - Fixed E999 syntax error in metadata_utils.py - Refactored 10+ complex functions (C901) - Updated error handling (S110, S112, SIM105) - Modernized type hints (UP038) - Fixed naming conflicts (A001, F811) BUG FIXES: - Added missing _on_update_cover() method (11 test failures) - Fixed BPM display and async loading - Improved thread safety TESTING: 30 passed, 1 skipped DOCUMENTATION: Windows PowerShell support, tox troubleshooting --- tests/test_info_tab_extensions.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_info_tab_extensions.py (limited to 'tests/test_info_tab_extensions.py') diff --git a/tests/test_info_tab_extensions.py b/tests/test_info_tab_extensions.py new file mode 100644 index 0000000..4288cc8 --- /dev/null +++ b/tests/test_info_tab_extensions.py @@ -0,0 +1,28 @@ +from unittest.mock import patch + + +def test_new_fields_initial_state(info_tab_widget, qt_app): + """New fields must exist and default to '—'.""" + assert hasattr(info_tab_widget, "lbl_track_number") + assert info_tab_widget.lbl_track_number.text() == "—" + assert hasattr(info_tab_widget, "lbl_bpm") + assert info_tab_widget.lbl_bpm.text() == "—" + # Note: lbl_label, lbl_genres, lbl_producers and lbl_composers are not available + # as these fields cannot be retrieved from TIDAL API + + +def test_bpm_population(info_tab_widget, mock_track, qt_app): + """Ensure BPM field is populated when present.""" + # Add BPM attribute to mock_track + mock_track.bpm = 120 + + with patch("tidal_dl_ng.ui.info_tab_widget.name_builder_title", return_value="Test Track"): + info_tab_widget._populate_track_details(mock_track) + qt_app.processEvents() + + # Expect loading indicator first due to async extras + assert info_tab_widget.lbl_bpm.text() == "⏳ Loading..." + # Simulate async arrival of extras + info_tab_widget._update_extras_ui({"bpm": 120}) + qt_app.processEvents() + assert info_tab_widget.lbl_bpm.text() == "120" -- cgit v1.3.1