예제 #1
0
    def test_error(self):
        from alsamidi import Seq
        import alsamidi

        alsamidi.open.side_effect = IOError
        seq = Seq()
        seq.write('path')
예제 #2
0
    def test_read_not_found(self):
        import os
        from alsamidi import Seq

        os.path.exists.return_value = False
        seq = Seq()
        seq.read('path')
        self.assertEqual([], seq.tracks)
예제 #3
0
    def test_read_default_track(self):
        from alsamidi import Seq

        text = '6,1,0,1,2 5430786,20 0,130 0,1 108 82 0 0'

        self.file.readlines.return_value = text.split('\n')
        seq = Seq()
        seq.read('path')
        self.assertEqual(['Default'], seq.names)
예제 #4
0
    def test_read_track(self):
        from alsamidi import Seq

        seq = Seq()
        seq.read('path')
        self.assertEqual([[
                (6, 1, 0, 1,
                (2, 5430786),
                (20, 0),
                (130, 0), (1, 108, 82, 0, 0))]], seq.tracks)
예제 #5
0
    def test_write_no_name(self):
        from alsamidi import Seq

        data = (9, 60, 127, 0, 10)
        event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
        track = [event]

        seq = Seq()
        seq.names = []
        seq.tags = {'name': 'value'}
        seq.orderedtags = ['name']
        seq.tracks = [track]

        seq.write('path')
        line = '5,1,0,0,1 0,0 0,0 0,9 60 127 0 10\n'
        self.file.write.assert_called_with(line)
예제 #6
0
    def test_info(self):
        from alsamidi import Seq
        import alsamidi

        data = (9, 60, 127, 0, 10)
        event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
        track = [event]

        seq = Seq()
        seq.names = ['name']
        seq.tags = 'tags'
        seq.tracks = [track]
        seq.info()
        alsamidi.print.assert_any_call('tags')
        args = '0:', 'name           ', 0, 'Sec.', 1, 'events,', {9: [60]}, 'Hi Bongo'
        alsamidi.print.assert_called_with(*args)
예제 #7
0
    def test_read_named_track(self):
        from alsamidi import Seq

        seq = Seq()
        seq.read('path')
        self.assertEqual(['track melody'], seq.names)