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('E-1major' + tests.test_musicxml.xml_note('E', alter=-1), '-3')) 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)