ytmusicapi/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
fischcode d143480ae4
Fix parsing of album and views in parse_playlist_items (#552)
* Fix parsing of album and views in parse_playlist_items

Parse album and views columns as a function of flex column count and is_album property to cater for varying layouts with three and four flex columns

* Add "own_playlist" attribute to playlists

To allow for an easy distinction between owned / editable and community / non-editable playlists,in applications incorporating ytmusicapi, a boolean "own_playlist" dictionary entry is added to playlists based on existing code already identifying this property.

* Add thumbnails to episodes

Add thumbnails to episodes for visual rendering in Kodi etc.

* Add unit test for playlist "own_playlist" attribut

Add unit test for playlist "own_playlist" attribut

* Improvements as requested

- rename attribute for own playlists to playlist("owned")
- filter out episode thumbnails with an non-functional URL

* Fix linter in test_playlists.py

Fix test for playlist["owned"]

* Auto-Formatting on playlists.py

* format parsers/podcasts.py

* Remove filtering of podcast thumbnails

No idea why I had seen useless images for those thumbnails before - maybe Google fixed something to make them work?
2024-02-27 09:23:09 +01:00
..
auth ruff: ruff specific rules 2024-01-18 21:53:23 +01:00
mixins Fix parsing of album and views in parse_playlist_items (#552) 2024-02-27 09:23:09 +01:00
setup Revert "get_charts: removed trending category (no longer available on YTM)" 2024-02-22 20:47:15 +01:00
__init__.py improve coverage 2024-01-02 22:29:41 +01:00
conftest.py add brand account setup script (#520) 2024-02-04 17:03:59 +01:00
README.rst add brand account setup script (#520) 2024-02-04 17:03:59 +01:00
test.example.cfg fix tests 2024-02-22 20:47:15 +01:00
test_ytmusic.py test restructuring via pytest 2024-01-02 22:09:22 +01:00

Package tests
============================================
Tests use the ``unittest`` framework. Each function has a corresponding unittest.
Sometimes there is a single unittest for multiple functions to ensure there are no permanent changes in the user's
YouTube account (i.e. subscribe and unsubscribe).

Note that there must be a ``browser.json`` and ``oauth.json`` in the `tests` folder to run all authenticated tests.
These two files can be easily obtained as the default outputs of running the following commands respectively:

.. code-block:: bash

    ytmusicapi browser
    ytmusicapi oauth



First, run

.. code-block:: bash

    cp tests/test.example.cfg tests/test.cfg

The entry descriptions should be self-explanatory.
For the headers_raw, you need to indent the overflowing lines with a tab character. For the upload test you need a suitable music file in the test directory.
Adjust the file to contain appropriate information for your YouTube account and local setup.

Brand accounts can be created by first signing into the google account you wish to have as the parent/controlling
account then navigating `here. <https://www.youtube.com/create_channel?action_create_new_channel_redirect=true>`_

Once the brand account/channel has been created, you can obtain the account ID needed for your test.cfg by
navigating to your `google account page <https://myaccount.google.com>`_ and selecting the brand account via the
profile drop down in the top right, the brand ID should then be present in the URL.

You can populate the brand account with content using the script provided in ``tests/setup/setup_account.py``.

Coverage badge
--------------
Make sure you installed the dev requirements as explained in `CONTRIBUTING.rst <https://github.com/sigma67/ytmusicapi/blob/master/CONTRIBUTING.rst>`_. Run

.. code-block:: bash

    pdm run pytest


to generate a coverage report.