pymedusa / Medusa

Automatic Video Library Manager for TV Shows. It watches for new episodes of your favorite shows, and when they are posted it does its magic.
https://pymedusa.com
GNU General Public License v3.0
1.74k stars 271 forks source link

Testing for providers requiring authorization #11691

Closed k0mmsussert0d closed 3 months ago

k0mmsussert0d commented 3 months ago

This PR demonstrates a proposed approach to testing torrent providers requiring authorization using animebytes as an example.

Authorization mechanism is a part of an individual provider implementation. Usually, it depends on credentials stored as attributes of a provider class. In this particular example of animebytes provider, username and passkey attributes store user-provided credentials.

When provider class is imported to the testing context, advanced configuration of the instance can performed by injecting custom attributes found in _meta.attr in the test YAML file.

To prevent credentials from getting leaked by VCR recording them in the request, VCR context configuration can be defined in _meta.vcr. In case of animebytes, credentials are supplied as username and torrent_pass query parameters, so they have to be stripped with filter_query_parameters=['username', 'torrent_pass'] param provided to use_cassette(). Reference

To sum up, this PR introduces:

medariox commented 3 months ago

Great job! Thank you for the exceptional effort 👍