Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

feat: use matrix for python tests #19

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ on: [push]

jobs:
pytest:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
include:
- os: windows-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.11"

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
Expand Down
14 changes: 7 additions & 7 deletions tests/test_command_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.asyncio
@patch("youtube_bz.commands.download.YouTubeAPI.Client.get_search_results")
@patch("youtube_bz.api.youtube.Client.get_search_results")
async def test_get_no_best_match(mock_search_results): # type: ignore
yt_initial_data = json.dumps(
{
Expand Down Expand Up @@ -40,7 +40,7 @@ async def test_get_no_best_match(mock_search_results): # type: ignore


@pytest.mark.asyncio
@patch("youtube_bz.commands.download.YouTubeAPI.Client.get_search_results")
@patch("youtube_bz.api.youtube.Client.get_search_results")
async def test_get_best_match(mock_search_results): # type: ignore
yt_initial_data = json.dumps(
{
Expand Down Expand Up @@ -85,7 +85,7 @@ async def test_get_best_match(mock_search_results): # type: ignore


@pytest.mark.asyncio
@patch("youtube_bz.commands.download.YouTubeAPI.Client.get_search_results")
@patch("youtube_bz.api.youtube.Client.get_search_results")
async def test_fail_get_best_match(mock_search_results): # type: ignore
mock_search_results.side_effect = aiohttp.ClientError()
artist_credit: ArtistCredit = {"name": "foo"}
Expand All @@ -100,15 +100,15 @@ async def test_fail_get_best_match(mock_search_results): # type: ignore
await get_best_match(release, track)


@patch("youtube_bz.commands.download.pytube.YouTube", autospec=pytube.YouTube)
@patch("pytube.YouTube", autospec=pytube.YouTube)
def test_download_video_audio(*_):
download_video_audio("AmEN!", "2TjcPpasesA")


@pytest.mark.asyncio
@patch("youtube_bz.commands.download.pytube.YouTube", autospec=pytube.YouTube)
@patch("youtube_bz.commands.download.MusicBrainzAPI.Client.lookup_release")
@patch("youtube_bz.commands.download.YouTubeAPI.Client.get_search_results")
@patch("pytube.YouTube", autospec=pytube.YouTube)
@patch("youtube_bz.api.musicbrainz.Client.lookup_release")
@patch("youtube_bz.api.youtube.Client.get_search_results")
async def test_download(mock_search_results, mock_lookup_release, *_): # type: ignore
yt_initial_data = json.dumps(
{
Expand Down
15 changes: 7 additions & 8 deletions youtube_bz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ def print_version() -> None:

async def run_command(args: argparse.Namespace):
verbose = args.verbose if "verbose" in args else False
match args.command:
case "download":
await commands.download(
args.mbid,
verbose,
)
case _:
print(f"Unknown command {args.command}")
if args.command == "download":
await commands.download(
args.mbid,
verbose,
)
else:
print(f"Unknown command {args.command}")


def get_command_parser() -> argparse.ArgumentParser:
Expand Down