Skip to content

Commit

Permalink
Fix silence.flag test diff (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathom authored May 14, 2024
1 parent ad73a01 commit c646c01
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/test_tagger.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
import shutil

import pytest
from mutagen.flac import FLAC
from util import arun

from streamrip.metadata import *

test_flac = "tests/silence.flac"
TEST_FLAC_ORIGINAL = "tests/silence.flac"
TEST_FLAC_COPY = "tests/silence_copy.flac"
test_cover = "tests/1x1_pixel.jpg"


def wipe_test_flac():
audio = FLAC(test_flac)
audio = FLAC(TEST_FLAC_COPY)
# Remove all tags
audio.delete()
audio.save()
Expand Down Expand Up @@ -55,9 +59,10 @@ def sample_metadata() -> TrackMetadata:


def test_tag_flac_no_cover(sample_metadata):
shutil.copy(TEST_FLAC_ORIGINAL, TEST_FLAC_COPY)
wipe_test_flac()
arun(tag_file(test_flac, sample_metadata, None))
file = FLAC(test_flac)
arun(tag_file(TEST_FLAC_COPY, sample_metadata, None))
file = FLAC(TEST_FLAC_COPY)
assert file["title"][0] == "testtitle"
assert file["album"][0] == "testalbum"
assert file["composer"][0] == "testcomposer"
Expand All @@ -72,12 +77,14 @@ def test_tag_flac_no_cover(sample_metadata):
assert file["tracktotal"][0] == "14"
assert file["date"][0] == "1998-02-13"
assert "purchase_date" not in file, file["purchase_date"]
os.remove(TEST_FLAC_COPY)


def test_tag_flac_cover(sample_metadata):
shutil.copy(TEST_FLAC_ORIGINAL, TEST_FLAC_COPY)
wipe_test_flac()
arun(tag_file(test_flac, sample_metadata, test_cover))
file = FLAC(test_flac)
arun(tag_file(TEST_FLAC_COPY, sample_metadata, test_cover))
file = FLAC(TEST_FLAC_COPY)
assert file["title"][0] == "testtitle"
assert file["album"][0] == "testalbum"
assert file["composer"][0] == "testcomposer"
Expand All @@ -94,3 +101,4 @@ def test_tag_flac_cover(sample_metadata):
with open(test_cover, "rb") as img:
assert file.pictures[0].data == img.read()
assert "purchase_date" not in file, file["purchase_date"]
os.remove(TEST_FLAC_COPY)

0 comments on commit c646c01

Please sign in to comment.