Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lyrics tests, do not search for empty metadata #5452

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Commits on Nov 22, 2024

  1. Configuration menu
    Copy the full SHA
    67e6432 View commit details
    Browse the repository at this point in the history
  2. Address failing google sources tests

    Two google sources failed to return the expected output. I looked into
    each case why parsing failed:
    
    - lyrics on musica.com contain <aside> Google Ads
    - each lyrics line on lacoccinelle.net is wrapped within alternating
      <em> and <strong> tags
    
    Thus remove these tags as part of the HTML cleanup logic.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    9a97bb0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c783b54 View commit details
    Browse the repository at this point in the history
  4. lyrics: isolate test configuration

    Create 'helpers.ConfigMixin' which sets up testing configuration.
    This is helpful for tests (e.g. test_lyrics.py) that only need the
    configuration and do not require temp dir.
    
    (#5102) Refactor lyrics tests to fix the issue global beets config
    issue.
    
    Additionally, add 'integration_test' mark that can be used to mark tests
    that should only run once a week.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    b63dded View commit details
    Browse the repository at this point in the history
  5. Refactor lyrics backend tests to use pytest fixtures

    - Replaced unittest.mock with pytest fixtures for better test isolation and readability.
    - Simplified test cases by using parameterized tests.
    - Added `requests-mock` dependency to `pyproject.toml` and `poetry.lock`.
    - Removed redundant helper functions and classes.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    5475c69 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    2d00541 View commit details
    Browse the repository at this point in the history
  7. Remove outdated GeniusLyrics test

    The test for GeniusLyrics was heavily patched and no longer provided
    useful coverage. It has been removed to clean up the test suite.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    f510e77 View commit details
    Browse the repository at this point in the history
  8. Refactor test_slug to pytest

    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    ae44207 View commit details
    Browse the repository at this point in the history
  9. Refactor search_pairs tests to use pytest parametrize

    - Consolidated multiple test cases into parameterized tests for better
      readability and maintainability.
    - Simplified assertions by comparing lists of actual and expected
      artists/titles.
    - Added `unexpected_empty_artist` marker to handle cases which
      unexpectedly return an empty artist. This seems to be happen when
      `artist_sort` field is empty.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    f32b034 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    cbcf980 View commit details
    Browse the repository at this point in the history
  11. Do not attempt to fetch lyrics with empty data

    Modified `search_pairs` function in `lyrics.py` to:
    
    * Firstly strip each of `artist`, `artist_sort` and `title` fields
    * Only generate alternatives if both `artist` and `title` are not empty
    * Ensure that `artist_sort` is not empty and not equal to artist (ignoring
      case) before appending it to the artists
    
    Extended tests to cover the changes.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    d0c8ff1 View commit details
    Browse the repository at this point in the history
  12. Remove pytest.param alias _p

    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    dd6ee95 View commit details
    Browse the repository at this point in the history
  13. Make album, duration required for LyricsPlugin.fetch

    Since at least one Backend requires album` and `duration` arguments
    (`LRCLib`), the caller (`LyricsPlugin.fetch_item_lyrics`) must always
    provide them.
    
    Since they need to provided, we need to enforce this by defining them as
    positional arguments.
    
    Why is this important? I found that integrated `LRCLib` tests have been
    passing, but they called `LRCLib.fetch` with values for `artist` and
    `title` fields only, while the actual functionality *always* provides
    values for `album` and `duration` fields too.
    
    When I adjusted the test to provide values for the missing fields,
    I found that it failed. This makes sense: Lib `album` and `duration`
    filters are strict on LRCLib, so I was not surprised the lyrics could
    not be found.
    
    Thus I adjusted `LRCLib` backend implementation to only filter by each
    of these fields when their values are truthy.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    0572213 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    94e16e6 View commit details
    Browse the repository at this point in the history
  15. Test lyrics texts explicitly

    Add explicit checks for lyrics texts fetched from the tested sources.
    
    - Introduced `LyricsPage` class to represent lyrics pages for integrated
      tests.
    - Configured expected lyrics for each of the URLs that are being
      fetched.
    - Consolidated integrated tests in a new `TestLyricsSources` class.
    - Mocked Google Search API to return the lyrics page under test.
    snejus committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    4970dda View commit details
    Browse the repository at this point in the history