Skip to content

Commit

Permalink
Testing for providers requiring authorization (#11691)
Browse files Browse the repository at this point in the history
* Set provider attributes for testing

* Add test cases for Animebytes
  • Loading branch information
k0mmsussert0d authored Apr 3, 2024
1 parent ae23e95 commit e3084ba
Show file tree
Hide file tree
Showing 5 changed files with 3,261 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tests/providers/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@


def get_providers():
from medusa.providers.torrent import (anidex, btdb, limetorrents, nyaa,
from medusa.providers.torrent import (anidex, animebytes, btdb, limetorrents, nyaa,
rarbg, shanaproject, thepiratebay,
tokyotoshokan, torrentz2, zooqle)
from medusa.providers.nzb import anizb, binsearch

return (anidex, btdb, limetorrents, nyaa, rarbg, shanaproject,
return (anidex, animebytes, btdb, limetorrents, nyaa, rarbg, shanaproject,
thepiratebay, tokyotoshokan, torrentz2, zooqle, anizb, binsearch)


Expand All @@ -40,6 +40,11 @@ def get_provider_data():
# Update provider with test data
provider.data.update(test_data)

# Configure provider by overriding instance attributes
if test_data.get("_meta", {}).get("attr"):
for k, v in test_data["_meta"]["attr"].items():
setattr(provider.klass, k, v)

return providers


Expand Down
7 changes: 6 additions & 1 deletion tests/providers/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def search(search_type, provider):
cassette_filename = '{0}_{1}.yaml'.format(provider.name, search_type)
cassette_path = os.path.join(__location__, provider.type, provider.name,
cassette_filename)
with vcr.use_cassette(cassette_path, record_mode=record_mode):
if provider.data.get("_meta", {}).get("vcr"):
vcr_config = provider.data["_meta"]["vcr"]
else:
vcr_config = {}

with vcr.use_cassette(cassette_path, record_mode=record_mode, **vcr_config):
actual = provider.klass.search(test_case['search_strings'])

# Check if we got any results
Expand Down
Loading

0 comments on commit e3084ba

Please sign in to comment.