def test_repeated_commas(self):
     command_region = as_region("song: tempo_bpm=80,, time_signature = 4/4,  ")
     with self.parse_exception("Extra data when parsing: ',, time_signature = 4/4,  '", ",, t"):
         values_command = SongCommand.parse(command_region)
     command_region = as_region("song: tempo_bpm=80, , time_signature = 4/4,  ")
     with self.parse_exception("Extra data when parsing: ', , time_signature = 4/4,  '", ", , t"):
         values_command = SongCommand.parse(command_region)
    def test_parse_groove(self):
        region = as_region("groove: 0 3")
        command = SongCommand.parse(region)
        self.assertEquals(command, GrooveCommand(delays=[0, 3]))

        region = as_region("groove: 0 wrong 3")
        with self.parse_exception('Invalid groove delay: "wrong"', "wrong 3"):
            command = SongCommand.parse(region)
    def test_parse_groove(self):
        region = as_region('groove: 0 3')
        command = SongCommand.parse(region)
        self.assertEquals(command, GrooveCommand(delays=[0, 3]))

        region = as_region('groove: 0 wrong 3')
        with self.parse_exception('Invalid groove delay: "wrong"', "wrong 3"):
            command = SongCommand.parse(region)
 def test_repeated_commas(self):
     command_region = as_region(
         'song: tempo_bpm=80,, time_signature = 4/4,  ')
     with self.parse_exception(
             "Extra data when parsing: ',, time_signature = 4/4,  '",
             ',, t'):
         values_command = SongCommand.parse(command_region)
     command_region = as_region(
         'song: tempo_bpm=80, , time_signature = 4/4,  ')
     with self.parse_exception(
             "Extra data when parsing: ', , time_signature = 4/4,  '",
             ', , t'):
         values_command = SongCommand.parse(command_region)
    def test_song_values_song_command(self):
        command_region = as_region(
            "song: tempo_bpm=80, time_signature = 4/4 ,ticks_per_beat = 12 , subticks_per_tick = 5 "
        )

        values_command = SongCommand.parse(command_region)
        self.assertEquals(values_command.source, command_region)
        self.assertEquals(
            values_command,
            SongValuesCommand(
                [SetSongTempoBpm(80), SetSongTimeSignature((4, 4)), SetSongTicksPerBeat(12), SetSongSubTicksPerTick(5)]
            ),
        )
    def test_song_values_song_command(self):
        command_region = as_region(
            'song: tempo_bpm=80, time_signature = 4/4 ,ticks_per_beat = 12 , subticks_per_tick = 5 '
        )

        values_command = SongCommand.parse(command_region)
        self.assertEquals(values_command.source, command_region)
        self.assertEquals(
            values_command,
            SongValuesCommand([
                SetSongTempoBpm(80),
                SetSongTimeSignature((4, 4)),
                SetSongTicksPerBeat(12),
                SetSongSubTicksPerTick(5)
            ]))