Files
product-vamp/tests/test_catalog.py
T
2026-10-05 19:44:33 -05:00

25 lines
1.1 KiB
Python

import tests.production_fixtures
import json
import pathlib
import tempfile
import unittest
import generator.arrange.generate
import tests.solo_fixtures
import tests.test_musicxml
class CatalogTests(unittest.TestCase):
def setUp(self):
tests.production_fixtures.install(self)
def test_songs_generate_only_authored_key_parts(self):
with tempfile.TemporaryDirectory() as temporary:
source, output = pathlib.Path(temporary) / 'songs', pathlib.Path(temporary) / 'output'
source.mkdir()
(source / 'song.xml').write_text(tests.test_musicxml.xml_score(tests.test_musicxml.xml_note('E', alter=-1), '<key><fifths>-3</fifths></key>'))
self.assertEqual(generator.arrange.generate.generate_performance_scores(source, output), 3)
self.assertEqual({p.name for p in output.iterdir()}, {'song_acoustic.json', 'song_electric.json', 'song_vocal.json'})
for path in output.iterdir():
metadata = json.loads(path.read_text())['metadata']
self.assertEqual(metadata['key_signature'], 'Eb')
self.assertNotIn('variant_tonic', metadata)