Initial SE Palette add-on
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from library import default_label, load_config, save_config, scan_audio_files
|
||||
|
||||
|
||||
class LibraryTests(unittest.TestCase):
|
||||
def test_scan_filters_and_sorts_supported_audio(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
for filename in ("02_b.WAV", "01_a.mp3", "memo.txt"):
|
||||
(root / filename).touch()
|
||||
self.assertEqual(
|
||||
[path.name for path in scan_audio_files(directory)],
|
||||
["01_a.mp3", "02_b.WAV"],
|
||||
)
|
||||
|
||||
def test_default_label_removes_number_prefix(self):
|
||||
self.assertEqual(default_label(Path("01_和太鼓でドン.mp3")), "和太鼓でドン")
|
||||
|
||||
def test_config_round_trip(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = save_config(
|
||||
directory,
|
||||
[{"filename": "se.mp3", "label": "SE", "icon": "INFO", "icon_path": ""}],
|
||||
)
|
||||
self.assertTrue(path.is_file())
|
||||
self.assertEqual(load_config(directory)["items"]["se.mp3"]["label"], "SE")
|
||||
json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user