25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
import generator.production
|
|
import tests.production_fixtures
|
|
import json
|
|
import pathlib
|
|
import tempfile
|
|
import unittest
|
|
|
|
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('<harmony><root><root-step>E</root-step><root-alter>-1</root-alter></root><kind>major</kind></harmony>' + tests.test_musicxml.xml_note('E', alter=-1), '<key><fifths>-3</fifths></key>'))
|
|
self.assertEqual(generator.production.generate_tree(source, output), 5)
|
|
self.assertEqual({p.name for p in output.iterdir()}, {'song_acoustic.json', 'song_acoustic_improv.json', 'song_electric.json', 'song_electric_improv.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)
|