示例#1
0
 def setUp(self):
     self.connector = Connector()
示例#2
0
 def setUp(self):
     self.connector = Connector()
示例#3
0
class TestConnector(unittest.TestCase):

    def setUp(self):
        self.connector = Connector()

    def test_create_set_sequence_message(self):
        self.connector.seq = 7
        actual = self.connector.create_set_sequence_message(
            4, False, [48, 48, 'x', 48, 48, 48, 60, 48])
        self.assertTrue(actual == SYSEX_SEQUENCE_FRAGMENT3)

    def test_create_set_sequence_messages(self):
        self.connector.seq = 71
        actual = self.connector.create_set_sequence_messages(STRING_SEQUENCE)
        self.assertTrue(actual == SYSEX_SEQUENCE_FRAGMENTS)

    def test_create_get_sequence_message(self):
        self.connector.seq = 0x2B
        actual = self.connector.create_get_sequence_message(4, 0x20)
        expected = [0x00, 0x20, 0x6B, 0x05, 0x01,
                    0x2B, 0x03, 0x3B, 0x04, 0x20, 0x20]
        self.assertTrue(actual == expected)

    def test_get_sequence_string(self):
        actual = self.connector.get_sequence_string(1, SYSEX_SEQUENCE)
        self.assertTrue(actual == STRING_SEQUENCE)

    def test_seq_inc(self):
        self.connector.seq_inc()
        self.assertTrue(self.connector.seq == 1)

    def test_seq_inc_limit(self):
        self.connector.seq = 0x7F
        self.connector.seq_inc()
        self.assertTrue(self.connector.seq == 0)

    def test_create_get_parameter_message(self):
        actual = self.connector.create_get_parameter_message(
            microdude.connector.RX_CHANNEL)
        self.assertTrue(actual == SYSEX_GET_MESSAGE)

    def test_create_set_parameter_message(self):
        self.connector.seq = 0x1
        actual = self.connector.create_set_parameter_message(
            microdude.connector.NOTE_PRIORITY, 0)
        self.assertTrue(actual == SYSEX_SET_MESSAGE)

    def test_create_set_sequence_messages_empty(self):
        try:
            self.connector.create_set_sequence_messages('')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_no_data(self):
        try:
            self.connector.create_set_sequence_messages('3:')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_bad_id(self):
        try:
            self.connector.create_set_sequence_messages('a:')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_bad_data(self):
        try:
            self.connector.create_set_sequence_messages('5: a')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)
示例#4
0
class TestConnector(unittest.TestCase):
    def setUp(self):
        self.connector = Connector()

    def test_create_set_sequence_message(self):
        self.connector.seq = 7
        actual = self.connector.create_set_sequence_message(
            4, False, [48, 48, 'x', 48, 48, 48, 60, 48])
        self.assertTrue(actual == SYSEX_SEQUENCE_FRAGMENT3)

    def test_create_set_sequence_messages(self):
        self.connector.seq = 71
        actual = self.connector.create_set_sequence_messages(STRING_SEQUENCE)
        self.assertTrue(actual == SYSEX_SEQUENCE_FRAGMENTS)

    def test_create_get_sequence_message(self):
        self.connector.seq = 0x2B
        actual = self.connector.create_get_sequence_message(4, 0x20)
        expected = [
            0x00, 0x20, 0x6B, 0x05, 0x01, 0x2B, 0x03, 0x3B, 0x04, 0x20, 0x20
        ]
        self.assertTrue(actual == expected)

    def test_get_sequence_string(self):
        actual = self.connector.get_sequence_string(1, SYSEX_SEQUENCE)
        self.assertTrue(actual == STRING_SEQUENCE)

    def test_seq_inc(self):
        self.connector.seq_inc()
        self.assertTrue(self.connector.seq == 1)

    def test_seq_inc_limit(self):
        self.connector.seq = 0x7F
        self.connector.seq_inc()
        self.assertTrue(self.connector.seq == 0)

    def test_create_get_parameter_message(self):
        actual = self.connector.create_get_parameter_message(
            microdude.connector.RX_CHANNEL)
        self.assertTrue(actual == SYSEX_GET_MESSAGE)

    def test_create_set_parameter_message(self):
        self.connector.seq = 0x1
        actual = self.connector.create_set_parameter_message(
            microdude.connector.NOTE_PRIORITY, 0)
        self.assertTrue(actual == SYSEX_SET_MESSAGE)

    def test_create_set_sequence_messages_empty(self):
        try:
            self.connector.create_set_sequence_messages('')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_no_data(self):
        try:
            self.connector.create_set_sequence_messages('3:')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_bad_id(self):
        try:
            self.connector.create_set_sequence_messages('a:')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)

    def test_create_set_sequence_messages_bad_data(self):
        try:
            self.connector.create_set_sequence_messages('5: a')
            self.assertTrue(False)
        except ValueError as e:
            self.assertTrue(str(e) == microdude.connector.SEQ_FILE_ERROR)