def get_chord(event): chord = extract_chord(event.message.text) if not chord: return {} audio = translate_chord(chord) audio.update({'file_name': '{}.wav'.format(chord)}) response = save_file(audio) if not response: return {} return {'url': response['url'], 'duration': audio['duration']}
def test_no_input(): assert extract_chord('') == ''
def test_lack_of_line_feed(): assert extract_chord('演奏してC') == 'C'
def test_major_seventh(): assert extract_chord('演奏して\nCM7') == 'CM7'
def test_single_major_chord(): assert extract_chord("演奏して\nC") == 'C'
def test_ending_with_number(): assert extract_chord('演奏して\nCadd9') == 'Cadd9'
def test_plural_chord(): assert extract_chord('演奏して\nF7G7Em7Am') == 'F7'
def test_no_chord(): assert extract_chord('foobar') == ''