@@ -1,3 +1,5 @@
|
||||
import generator.production
|
||||
import generator.validation
|
||||
import tests.production_fixtures
|
||||
import argparse
|
||||
import copy
|
||||
@@ -74,7 +76,7 @@ class GuitarTests(unittest.TestCase):
|
||||
self.assertEqual(document, before)
|
||||
document['staves'][0]['tablature'] = True
|
||||
with self.assertRaisesRegex(ValueError, 'invalid generated tablature'):
|
||||
generator.model.validate_document(document)
|
||||
generator.validation.validate_document(document)
|
||||
def test_theory_controls_omissions_and_bass(self):
|
||||
for symbol in ('CM', 'G7b9', 'FM7#11/A', 'CmM7', 'Cdim7', 'C13', 'Csus', 'Cmadd9'):
|
||||
with self.subTest(symbol=symbol):
|
||||
@@ -135,7 +137,7 @@ class GuitarTests(unittest.TestCase):
|
||||
before = copy.deepcopy(source)
|
||||
electric = tests.arrangement_fixtures.section_document(source, 'electric')
|
||||
vocal = tests.arrangement_fixtures.section_document(source, 'vocal')
|
||||
generator.model.validate_document(electric)
|
||||
generator.validation.validate_document(electric)
|
||||
self.assertEqual(source, before)
|
||||
self.assertEqual([(e['onset'], e['duration'], generator.model.fraction(e['pitch']) - 12) for e in tests.score_events.timeline(electric)['events']], [(e['onset'], e['duration'], generator.model.fraction(e['pitch'])) for e in tests.score_events.timeline(vocal)['events']])
|
||||
self.assertEqual([(e['pitch'], e['onset'], e['duration']) for e in tests.score_events.timeline(electric)['events']], [(e['pitch'], e['onset'], e['duration']) for e in tests.score_events.timeline(source)['events']])
|
||||
@@ -156,7 +158,7 @@ class GuitarTests(unittest.TestCase):
|
||||
self.assertEqual(generator.model.pitch_number(tone), 12 * (octave + 1) + alter)
|
||||
self.assertEqual(tone['tablature'], tab)
|
||||
self.assertEqual(generator.model.fraction(tests.score_events.timeline(document)['events'][0]['pitch']), expected)
|
||||
generator.model.validate_document(document)
|
||||
generator.validation.validate_document(document)
|
||||
def test_guitar_normalization_is_idempotent_and_respects_timed_transposition(self):
|
||||
change = '<attributes><transpose><chromatic>0</chromatic></transpose></attributes>'
|
||||
source = tests.test_musicxml.parse(tests.test_musicxml.xml_score(tests.test_musicxml.xml_note(duration=2, kind='half') + change + tests.test_musicxml.xml_note(duration=2, kind='half')))
|
||||
@@ -173,7 +175,7 @@ class GuitarTests(unittest.TestCase):
|
||||
for part in generator.parts.PART_TYPES:
|
||||
with self.subTest(generator=generate.__name__, part=part):
|
||||
document = generate(source, part)
|
||||
generator.model.validate_document(document)
|
||||
generator.validation.validate_document(document)
|
||||
written = {p['id']: generator.model.pitch_number(p) for m in document['staves'][0]['measures'] for v in m['voices'] for n in v['notes'] for p in n['pitches']}
|
||||
events = tests.score_events.timeline(document)['events']
|
||||
self.assertTrue(events)
|
||||
@@ -231,7 +233,7 @@ class GuitarTests(unittest.TestCase):
|
||||
chord['pitches'] = []
|
||||
chord['_harmony'] = generator.harmony.parse_symbol('CM')
|
||||
generator.guitar.place_guitar(document)
|
||||
generator.model.validate_document(document)
|
||||
generator.validation.validate_document(document)
|
||||
self.assertEqual(melody['pitches'][0]['tablature'], {'string': 1, 'fret': 12})
|
||||
self.assertNotIn(1, [p['tablature']['string'] for p in chord['pitches']])
|
||||
self.assertEqual(len(tests.score_events.timeline(document)['events']), 3)
|
||||
@@ -256,9 +258,9 @@ class GuitarTests(unittest.TestCase):
|
||||
source, output = pathlib.Path(temporary) / 'source', pathlib.Path(temporary) / 'output'
|
||||
source.mkdir()
|
||||
(source / '0000.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.arrange.generate.generate_performance_scores(source, output), 3)
|
||||
self.assertEqual(generator.production.generate_tree(source, output), 3)
|
||||
first = {p.name: p.read_bytes() for p in output.rglob('*.json')}
|
||||
generator.arrange.generate.generate_performance_scores(source, output)
|
||||
generator.production.generate_tree(source, output)
|
||||
self.assertEqual(first, {p.name: p.read_bytes() for p in output.rglob('*.json')})
|
||||
def test_unplayable_generation_preserves_previous_assets(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
|
||||
Reference in New Issue
Block a user