def test_exceptions(self): too_low = chant.Note('E3') self.assertRaises(Exception, lambda: chant.pitchToVolpiano(too_low.pitch)) too_high = chant.Note('E6') self.assertRaises(Exception, lambda: chant.pitchToVolpiano(too_high.pitch))
def test_pitchConversion(self): lowest = chant.Note('F3') highest = chant.Note('D6') volpianoNotes = '89abcdefghjklmnopqrs' i = 0 for octave in [3, 4, 5, 6]: for noteName in 'CDEFGAB': n = chant.Note(f'{noteName}{octave}') if lowest <= n and n <= highest: volpiano = chant.pitchToVolpiano(n.pitch) self.assertEqual(volpiano, volpianoNotes[i]) self.assertEqual(n.volpiano, volpianoNotes[i]) i += 1
def test_neume(self): n = chant.Neume() c = chant.Note('C4') d = chant.Note('D4') n.append([c, d]) targetObj = { 'type': 'neume', 'elements': [{ 'pitch': 'C4', 'type': 'note' }, { 'pitch': 'D4', 'type': 'note' }] } self.assertDictEqual(n.toObject(), targetObj)
def test_noteWithEditorialInfo(self): n = chant.Note('D-4') n.editorial.foo = 'bar' targetObj = { 'pitch': 'D-4', 'type': 'note', 'editorial': { 'foo': 'bar' } } self.assertDictEqual(n.toObject(), targetObj)
def test_note(self): n = chant.Note() obj = { 'type': 'note', 'pitch': 'D-4', 'editorial': { 'foo': 'bar' }, 'notehead': 'x' } n.fromObject(obj) self.assertEqual(n.pitch.nameWithOctave, 'D-4') self.assertEqual(n.notehead, 'x') self.assertEqual(n.editorial.foo, 'bar')
def test_liquescence(self): n = chant.Note('C4') n.editorial.liquescence = True self.assertEqual(n.volpiano, 'C')
def test_note(self): n = chant.Note('D-4') targetObj = {'pitch': 'D-4', 'type': 'note'} self.assertDictEqual(n.toObject(), targetObj)