19 lines
768 B
Python
19 lines
768 B
Python
import unittest
|
|
from worker import compact
|
|
|
|
|
|
class CompactNotesTest(unittest.TestCase):
|
|
def test_hand_split_and_velocity(self):
|
|
notes = compact([{'midi_note': 48, 'onset_time': 1.23456, 'offset_time': 1.78, 'velocity': 85}, {'midi_note': 60, 'onset_time': 2, 'offset_time': 3, 'velocity': 200}])
|
|
self.assertEqual(notes[0], {'pitch': 48, 'start': 1.235, 'end': 1.78, 'velocity': 85, 'hand': 'left'})
|
|
self.assertEqual(notes[1]['hand'], 'right')
|
|
self.assertEqual(notes[1]['velocity'], 127)
|
|
|
|
def test_empty_or_zero_duration(self):
|
|
self.assertEqual(compact([]), [])
|
|
self.assertEqual(compact([{'midi_note': 60, 'onset_time': 2, 'offset_time': 2, 'velocity': 85}]), [])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|