ytmusicapi/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
sigma67 3f186d4e00
Add option to pass raw headers to setup() (in place of terminal input)
Based on this change, coverage now runs without user input
2020-05-19 15:49:55 +02:00
..
coverage.svg Add more tests 2020-05-18 17:53:17 +02:00
README.rst Update coverage instructions and badge 2020-05-18 16:42:03 +02:00
test.cfg.example Add option to pass raw headers to setup() (in place of terminal input) 2020-05-19 15:49:55 +02:00
test.py Add option to pass raw headers to setup() (in place of terminal input) 2020-05-19 15:49:55 +02: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 ``headers_auth.json`` in the project root to run authenticated tests.
For testing the song upload, there also needs to be a file with the name specified in the code in the project root.

Copy ``tests/test.cfg.example`` to ``test.cfg`` in the project root to run tests with coverage.
Adjust the file to contain appropriate information for your YouTube account and local setup.

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

    cd tests
    coverage run --source=../ytmusicapi -m unittest test.py


to generate a coverage report. With

.. code-block:: bash

    coverage-badge -o coverage.svg -f

you generate the badge.