Migrate playability_analyzer_test to pytest
This commit is contained in:
parent
efcbd26447
commit
b37a095414
|
@ -1,97 +1,48 @@
|
||||||
from airtime_analyzer.playability_analyzer import *
|
import pytest
|
||||||
from nose.tools import *
|
from airtime_analyzer.playability_analyzer import (
|
||||||
|
PlayabilityAnalyzer,
|
||||||
|
UnplayableFileError,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_default_metadata(metadata):
|
@pytest.mark.parametrize(
|
||||||
"""Stub function for now in case we need it later."""
|
"filepath",
|
||||||
pass
|
[
|
||||||
|
("tests/test_data/44100Hz-16bit-mono.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-dualmono.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo-utf8.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-simplestereo.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-jointstereo.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-mp3-missingid3header.mp3"),
|
||||||
|
("tests/test_data/44100Hz-16bit-mono.ogg"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo.ogg"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo-invalid.wma"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo.m4a"),
|
||||||
|
("tests/test_data/44100Hz-16bit-stereo.wav"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_analyze(filepath):
|
||||||
|
PlayabilityAnalyzer.analyze(filepath, dict())
|
||||||
|
|
||||||
|
|
||||||
def test_missing_liquidsoap():
|
def test_missing_liquidsoap():
|
||||||
old_ls = PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE
|
old = PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE
|
||||||
PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE = "foosdaf"
|
PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE = "foobar"
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
PlayabilityAnalyzer.analyze("tests/test_data/44100Hz-16bit-mono.mp3", dict())
|
||||||
u"tests/test_data/44100Hz-16bit-stereo-utf8.mp3", dict()
|
PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE = old
|
||||||
)
|
|
||||||
PlayabilityAnalyzer.LIQUIDSOAP_EXECUTABLE = old_ls # Need to put this back
|
|
||||||
|
|
||||||
|
|
||||||
@raises(UnplayableFileError)
|
|
||||||
def test_invalid_filepath():
|
def test_invalid_filepath():
|
||||||
metadata = PlayabilityAnalyzer.analyze(u"non-existent-file", dict())
|
with pytest.raises(UnplayableFileError):
|
||||||
|
test_analyze("non-existent-file")
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_utf8():
|
# def test_invalid_wma():
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
# with pytest.raises(UnplayableFileError):
|
||||||
u"tests/test_data/44100Hz-16bit-stereo-utf8.mp3", dict()
|
# test_analyze("tests/test_data/44100Hz-16bit-stereo-invalid.wma")
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_dualmono():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-dualmono.mp3", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_jointstereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-jointstereo.mp3", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_simplestereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-simplestereo.mp3", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_stereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-stereo.mp3", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mp3_mono():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-mono.mp3", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_ogg_stereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-stereo.ogg", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
@raises(UnplayableFileError)
|
|
||||||
def test_invalid_wma():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-stereo-invalid.wma", dict()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_m4a_stereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-stereo.m4a", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
def test_wav_stereo():
|
|
||||||
metadata = PlayabilityAnalyzer.analyze(
|
|
||||||
u"tests/test_data/44100Hz-16bit-stereo.wav", dict()
|
|
||||||
)
|
|
||||||
check_default_metadata(metadata)
|
|
||||||
|
|
||||||
|
|
||||||
@raises(UnplayableFileError)
|
|
||||||
def test_unknown():
|
def test_unknown():
|
||||||
metadata = PlayabilityAnalyzer.analyze(u"http://www.google.com", dict())
|
with pytest.raises(UnplayableFileError):
|
||||||
check_default_metadata(metadata)
|
test_analyze("https://www.google.com")
|
||||||
|
|
Loading…
Reference in New Issue