ytmusicapi/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
sigma67 b86654fbaf
Added Lyrics w. Timestamps #662 (#693)
* Added Lyrics w. Timestamps

Added `get_lyrics_with_timestamps` to get lyrics with timestamps.
The Method doesn't try to parse the response as normal lyrics, if no lyrics with timestamps are returned. (could be changed to do so tho, the format is the same)

* Update browsing.py

* Combined both get_lyrics methods into one and fixed some typechecking errors

* Fixed a missing hasTimestamps and added the doccomments to the overloads, because vscode didn't show them otherwise

* Removed the old get_lyrics_with_timestamps method

because idk where it came from...

* fixed remaining issues

* Update uploads.py

reverted some changes that I moved to an extra PR

* removed variable `context` from the Mixin, as it's use was replaced by `yt.as_mobile()`

* fix some formatting complaints by ruff and mypy

* please the linter

* fix union syntax

* improve typing in ytmusic.py

* improve typing

* replace docsbuild.yml with RTD

---------

Co-authored-by: Hendrik Horstmann <65970327+heinrich26@users.noreply.github.com>
Co-authored-by: henrich26 <hendrik-horstmann@o2mail.de>
2024-12-17 22:12:06 +01:00
..
auth Add optional parameters for OAuth client ID and secret to setup (#688) 2024-12-17 13:15:33 +01:00
data get_playlist: join multiple title runs (#667) 2024-12-17 21:20:33 +01:00
mixins Added Lyrics w. Timestamps #662 (#693) 2024-12-17 22:12:06 +01:00
setup podcasts features ✨ (#559) 2024-03-06 23:02:19 +01:00
__init__.py improve coverage 2024-01-02 22:29:41 +01:00
conftest.py Add optional parameters for OAuth client ID and secret to setup (#688) 2024-12-17 13:15:33 +01:00
README.rst Docstring cleanup (#665) 2024-12-17 21:35:44 +01:00
test.example.cfg Add optional parameters for OAuth client ID and secret to setup (#688) 2024-12-17 13:15:33 +01:00
test_helpers.py fix #642: create_playlist: raise error when invalid characters are pa… (#652) 2024-10-05 11:31:11 +02: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.

``account_name`` and ``channel_handle`` for test.cfg can be obtained by visiting either YouTube or YouTube Music and
clicking your profile picture icon in the top right while signed in with your test account.

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.