mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 09:50:41 +00:00
Improved test coverage and touching up docs.
This commit is contained in:
@@ -8,6 +8,26 @@ class TestCue(TestCase):
|
|||||||
self.test_files = glob("tests/test_files/cue_chunks/*.wav")
|
self.test_files = glob("tests/test_files/cue_chunks/*.wav")
|
||||||
return super().setUp()
|
return super().setUp()
|
||||||
|
|
||||||
|
def test_enumerate(self):
|
||||||
|
file1 = "tests/test_files/cue_chunks/STE-000.wav"
|
||||||
|
w1 = wavinfo.WavInfoReader(file1)
|
||||||
|
self.assertIsNotNone(w1.cues)
|
||||||
|
vals = list(w1.cues.each_cue())
|
||||||
|
self.assertEqual(vals, [(1,29616),(2,74592),(3,121200)])
|
||||||
|
|
||||||
|
def test_labels_notes(self):
|
||||||
|
file = "tests/test_files/cue_chunks/izotoperx_cues_test.wav"
|
||||||
|
w1 = wavinfo.WavInfoReader(file)
|
||||||
|
self.assertIsNotNone(w1.cues)
|
||||||
|
assert w1.cues is not None
|
||||||
|
|
||||||
|
for name, _ in w1.cues.each_cue():
|
||||||
|
self.assertIn(name,[1,2,3])
|
||||||
|
label, note = w1.cues.label_and_note(name)
|
||||||
|
if name == 1:
|
||||||
|
self.assertEqual("Marker 1", label)
|
||||||
|
self.assertIsNone(note)
|
||||||
|
|
||||||
def test_encoding_fallback(self):
|
def test_encoding_fallback(self):
|
||||||
"""
|
"""
|
||||||
Added this after I noticed that iZotope RX seems to just encode "notes"
|
Added this after I noticed that iZotope RX seems to just encode "notes"
|
||||||
@@ -19,6 +39,7 @@ class TestCue(TestCase):
|
|||||||
expected = ("Лорем ипсум долор сит амет, тимеам вивендум хас ет, "
|
expected = ("Лорем ипсум долор сит амет, тимеам вивендум хас ет, "
|
||||||
"цу адолесценс дефинитионес еам.")
|
"цу адолесценс дефинитионес еам.")
|
||||||
|
|
||||||
|
assert w.cues is not None
|
||||||
note = [n for n in w.cues.notes if n.name == 3]
|
note = [n for n in w.cues.notes if n.name == 3]
|
||||||
self.assertEqual(len(note), 1)
|
self.assertEqual(len(note), 1)
|
||||||
self.assertEqual(note[0].text, expected)
|
self.assertEqual(note[0].text, expected)
|
||||||
@@ -28,17 +49,18 @@ class TestCue(TestCase):
|
|||||||
w = wavinfo.WavInfoReader(file)
|
w = wavinfo.WavInfoReader(file)
|
||||||
|
|
||||||
self.assertIsNotNone(w.cues)
|
self.assertIsNotNone(w.cues)
|
||||||
|
assert w.cues is not None
|
||||||
|
|
||||||
self.assertEqual(len(w.cues.labels), 3)
|
self.assertEqual(len(w.cues.labels), 3)
|
||||||
for label in w.cues.labels:
|
for label in w.cues.labels:
|
||||||
|
self.assertIn(label.name, [1,2,3])
|
||||||
if label.name == 1:
|
if label.name == 1:
|
||||||
self.assertEqual(label.text, "Marker 1")
|
self.assertEqual(label.text, "Marker 1")
|
||||||
elif label.name == 2:
|
elif label.name == 2:
|
||||||
self.assertEqual(label.text, "Marker 2")
|
self.assertEqual(label.text, "Marker 2")
|
||||||
elif label.name == 3:
|
elif label.name == 3:
|
||||||
self.assertEqual(label.text, "Marker 3")
|
self.assertEqual(label.text, "Marker 3")
|
||||||
else:
|
|
||||||
self.fail(f"Encountered unexpected label id {label.name}")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ class WavCuesReader:
|
|||||||
def each_cue(self) -> Generator[Tuple[int, int], None, None]:
|
def each_cue(self) -> Generator[Tuple[int, int], None, None]:
|
||||||
"""
|
"""
|
||||||
Iterate through each cue.
|
Iterate through each cue.
|
||||||
|
|
||||||
:yields: the cue's ``name`` and ``sample_offset``
|
:yields: the cue's ``name`` and ``sample_offset``
|
||||||
"""
|
"""
|
||||||
for cue in self.cues:
|
for cue in self.cues:
|
||||||
@@ -223,6 +224,7 @@ class WavCuesReader:
|
|||||||
def label_and_note(self, cue_ident: int) -> Tuple[Optional[str], Optional[str]]:
|
def label_and_note(self, cue_ident: int) -> Tuple[Optional[str], Optional[str]]:
|
||||||
"""
|
"""
|
||||||
Get the label and note (extended comment) for a cue.
|
Get the label and note (extended comment) for a cue.
|
||||||
|
|
||||||
:param cue_ident: the cue's name, it's unique identifying number
|
:param cue_ident: the cue's name, it's unique identifying number
|
||||||
:returns: a tuple of the the cue's label (if present) and note (if
|
:returns: a tuple of the the cue's label (if present) and note (if
|
||||||
present)
|
present)
|
||||||
|
|||||||
Reference in New Issue
Block a user