@@ -1,3 +1,4 @@
|
||||
import generator.audio_assets
|
||||
import argparse
|
||||
import copy
|
||||
import hashlib
|
||||
@@ -41,7 +42,7 @@ def fixture(root):
|
||||
with wave.open(str(path), 'wb') as output:
|
||||
output.setparams((2, 2, 48000, 0, 'NONE', ''))
|
||||
output.writeframes(value.to_bytes(2, 'little', signed=True) * 2 * frames)
|
||||
entries.append(generator.performance.describe_wav(path, root, song_id=song_id, bpm=bpm))
|
||||
entries.append(generator.audio_assets.describe_wav(path, root, song_id=song_id, bpm=bpm))
|
||||
(root / 'manifest.audio').write_text(json.dumps(entries))
|
||||
|
||||
class PerformanceTests(unittest.TestCase):
|
||||
@@ -49,7 +50,7 @@ class PerformanceTests(unittest.TestCase):
|
||||
source = pathlib.Path('package/assets')
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = pathlib.Path(temporary)
|
||||
entries = generator.performance.copy_audio(source, root, {'all_of_me', 'autumn_leaves'})
|
||||
entries = generator.audio_assets.copy_audio(source, root, {'all_of_me', 'autumn_leaves'})
|
||||
self.assertEqual(len(entries), 4)
|
||||
for entry in entries:
|
||||
self.assertEqual((source / entry['path']).read_bytes(), (root / entry['path']).read_bytes())
|
||||
@@ -61,10 +62,10 @@ class PerformanceTests(unittest.TestCase):
|
||||
path = root / 'backing/fixture_120.wav'
|
||||
path.write_bytes(path.read_bytes()[:-2])
|
||||
with self.assertRaisesRegex(ValueError, 'truncated'):
|
||||
generator.performance.describe_wav(path, root)
|
||||
generator.audio_assets.describe_wav(path, root)
|
||||
path.rename(root / 'backing/fixture_115.wav')
|
||||
with self.assertRaisesRegex(ValueError, 'unsupported'):
|
||||
generator.performance.copy_audio(root, root / 'out', {'fixture'})
|
||||
generator.audio_assets.copy_audio(root, root / 'out', {'fixture'})
|
||||
def test_short_backing_cannot_publish(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = pathlib.Path(temporary)
|
||||
@@ -73,10 +74,10 @@ class PerformanceTests(unittest.TestCase):
|
||||
bundle = json.loads((root / 'score.json').read_text())
|
||||
(root / 'songs/fixture.json').write_text(json.dumps(bundle['music']))
|
||||
entries = json.loads((root / 'manifest.audio').read_text())
|
||||
generator.performance.validate_recording_lengths(root, entries)
|
||||
generator.audio_assets.validate_recording_lengths(root, entries)
|
||||
entries[-1]['frames'] = 1
|
||||
with self.assertRaisesRegex(ValueError, 'shorter'):
|
||||
generator.performance.validate_recording_lengths(root, entries)
|
||||
generator.audio_assets.validate_recording_lengths(root, entries)
|
||||
def test_page_coverage_and_measure_accents(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = pathlib.Path(temporary)
|
||||
|
||||
Reference in New Issue
Block a user