Replaced old test with a parametrized test that tests every file type.

This commit is contained in:
The Wobbler 2025-03-30 18:33:22 +02:00
parent a7d9500e57
commit b6a73864ea
11 changed files with 37 additions and 55 deletions

Binary file not shown.

View file

@ -1,55 +0,0 @@
#!/usr/bin/python3
import pytest
from io import BytesIO
from smalltag import SmallTag
def test_written_gets_recognized():
# avoid writing to the real file by using a BytesIO
tag = SmallTag.get("formats/test.mp3", file_obj=BytesIO(b""))
tag.title = "A normal title."
tag.artist = "An artist."
tag.album = "The album."
tag.track = 1234
tag.other["url"] = ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]
tag = SmallTag.get("formats/test.mp3", file_obj=BytesIO(tag.compose_tag()))
assert tag.title == "A normal title."
assert tag.artist == "An artist."
assert tag.album == "The album."
assert tag.track == 1234
assert tag.other["url"] == ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]
# chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
# no "b" because there is a bug in TinyTag 2.1.0 that removes "b"s if they are at the beginning of a string
chars = "acdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _-"
@pytest.mark.slow
def test_full_written_gets_recognized():
for char1 in chars:
for char2 in chars:
field_content = f"{char1}{char2}Test{char2}{char1}"
tag = SmallTag.get("formats/test.mp3")
tag.title = field_content
tag.artist = field_content
tag.album = field_content
tag.track = 1234
tag.other["url"] = ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]
tag.write()
tag = SmallTag.get("formats/test.mp3")
assert tag.title == field_content
assert tag.artist == field_content
assert tag.album == field_content
assert tag.track == 1234
assert tag.other["url"] == ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]

37
tests/test_all_formats.py Normal file
View file

@ -0,0 +1,37 @@
#!/usr/bin/python3
import pytest
from smalltag import SmallTag
to_test = [
".mp1", ".mp2", ".mp3",
".oga", ".ogg", ".opus", ".spx",
".wav",
".flac",
".wma",
".m4b", ".m4a", ".m4r", ".m4v", ".mp4", ".aax", ".aaxc",
".aiff", ".aifc", ".aif", ".afc"
]
@pytest.mark.parametrize("file_type", to_test)
def test_writing_working(file_type: str):
tag = SmallTag.get("test_files/test" + file_type)
tag.title = "A normal title."
tag.artist = "An artist."
tag.album = "The album."
tag.track = 4321
tag.other["url"] = ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]
tag.write()
tag = SmallTag.get("test_files/test" + file_type)
assert tag.title == "A normal title."
assert tag.artist == "An artist."
assert tag.album == "The album."
assert tag.track == 4321
assert tag.other["url"] == ["https://teapot.informationsanarchistik.de/Wobbl/SmallTag"]

BIN
tests/test_files/test.flac Normal file

Binary file not shown.

BIN
tests/test_files/test.m4a Normal file

Binary file not shown.

BIN
tests/test_files/test.mp2 Normal file

Binary file not shown.

BIN
tests/test_files/test.mp3 Normal file

Binary file not shown.

BIN
tests/test_files/test.ogg Normal file

Binary file not shown.

BIN
tests/test_files/test.opus Normal file

Binary file not shown.

BIN
tests/test_files/test.wav Normal file

Binary file not shown.

BIN
tests/test_files/test.wma Normal file

Binary file not shown.