ytmusicapi/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
John Birdwell ba71fc998d
get_album: track positions (#510)
* get_album (via parse_playlist_items): add track_position key + tests for the badly indexed album

* get_album & parse_playlist_items: nav changes

* parse_playlist_items: only add track_position for albums

* parse_playlist_items & related test_browsing: track_position > track_number

---------

Co-authored-by: sigma67 <sigma67.github@gmail.com>
2024-01-11 20:02:23 +01:00
..
auth fix #501 (#502) 2024-01-03 21:15:00 +01:00
mixins get_album: track positions (#510) 2024-01-11 20:02:23 +01:00
__init__.py improve coverage 2024-01-02 22:29:41 +01:00
conftest.py get_album: track positions (#510) 2024-01-11 20:02:23 +01:00
README.rst test restructuring via pytest 2024-01-02 22:09:22 +01:00
test.cfg.example tests: further edits for clarity and oauth tests 2023-12-28 18:23:51 -06: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



Copy ``tests/test.cfg.example`` to ``tests/test.cfg`` to run the tests. 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.

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.