Files
product-vamp/tests/test_catalog.py
T
2026-10-04 09:05:25 -05:00

27 lines
1.2 KiB
Python

import tests.production_fixtures
import json
import pathlib
import tempfile
import unittest
import generator.arrange.generate
import tests.rhythm_fixtures
import tests.scale_fixtures
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, rhythms=tests.rhythm_fixtures.library(), scales=tests.scale_fixtures.library(), sequences=tests.solo_fixtures.library()), 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)