Skip to content

Commit

Permalink
Test tag and encode
Browse files Browse the repository at this point in the history
  • Loading branch information
john-kurkowski committed Oct 28, 2023
1 parent 5b619c9 commit e293be2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/__snapshots__/test_tag.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# serializer version: 1
# name: test_main
''
# ---
# name: test_main.1
_Call(
tuple(
list([
'lame',
'--preset',
'standard',
'--ta',
'Bluu',
'--tl',
'Album Title Here',
'--tn',
'01',
'--tt',
'Song Title Here',
'TMP_PATH_HERE/path/to/Album Title Here/01 - Song Title Here.wav',
'TMP_PATH_HERE/path/to/Album Title Here/01 - Song Title Here.mp3',
]),
),
dict({
}),
)
# ---
28 changes: 28 additions & 0 deletions tests/test_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Tag and encode tests."""

from pathlib import Path
from unittest import mock

from click.testing import CliRunner
from music.__main__ import tag
from syrupy.assertion import SnapshotAssertion


@mock.patch("subprocess.check_call")
def test_main(
mock_subprocess: mock.Mock, snapshot: SnapshotAssertion, tmp_path: Path
) -> None:
"""Test main calls the expected subprocess."""
some_path = (
tmp_path / "path" / "to" / "Album Title Here" / "01 - Song Title Here.wav"
)
some_path.parent.mkdir(parents=True, exist_ok=True)
some_path.touch()

result = CliRunner(mix_stderr=False).invoke(tag, [str(some_path)])

assert not result.stderr
assert not result.exception
assert result.stdout == snapshot

assert mock_subprocess.call_args == snapshot

0 comments on commit e293be2

Please sign in to comment.