'Verify that is_drum instruments are properly tracked.
self.midi_is_drum_filename is a MIDI file containing two tracks
set to channel 9 (is_drum == True). Each contains one NoteOn. This
test is designed to catch a bug where the second track would lose
is_drum, remapping the drum track to an instrument track.'

def testIsDrumDetection(self):

    sequence_proto = midi_io.midi_file_to_sequence_proto(self.midi_is_drum_filename)
    with tempfile.NamedTemporaryFile(prefix='MidiDrumTest') as temp_file:
        midi_io.sequence_proto_to_midi_file(sequence_proto, temp_file.name)
        midi_data1 = mido.MidiFile(filename=self.midi_is_drum_filename)
        midi_data2 = mido.MidiFile(filename=temp_file.name)
    channel_counts = [0, 0]
    for (index, midi_data) in enumerate([midi_data1, midi_data2]):
        for event in midi_data:
            if ((event.type == 'note_on') and (event.velocity > 0) and (event.channel == 9)):
                channel_counts[index] += 1
    self.assertEqual(channel_counts, [2, 2])
