Ejemplo n.º 1
0
 def test_throws_exception_if_index_out_of_range(self):
     p = PresetIndex()
     p.count = 4
     p.set_indexes([0, 1, 2, 3, 255])
     self.assertEqual(p.number_of_presets, 4)
     self.assertFalse(p.is_valid_index(4))
     self.assertFalse(p.is_valid_index(-1))
     self.assertTrue(p.is_valid_index(0))
     self.assertTrue(p.is_valid_index(1))
     self.assertTrue(p.is_valid_index(3))
Ejemplo n.º 2
0
    def test_adding_preset_modifies_both_index_and_preset(self):
        p = Preset()
        p.index = 123

        pi = PresetIndex()
        pi.set_indexes([0, 1, 2, 3, 255])

        pi.add_to_index(p)
        self.assertEqual(p.memory_slot, 4)
        self.assertEqual(pi.index_of_preset_with_memory_slot_number(4), 4)
        print "PI: {0}".format(pi.indexes)
Ejemplo n.º 3
0
    def test_deleting_shuffles_indexes_left(self):
        p = PresetIndex()
        p.set_indexes([0, 1, 2, 3, 255])
        self.assertEqual(4, p.number_of_presets)

        expected_index_list = list(p.indexes)
        del expected_index_list[0]
        expected_index_list.append(255)

        # logger.info("Is now: {0}".format(p.indexes))
        p.delete_item_at_index(0)
        self.assertEqual(expected_index_list, p.indexes)
        self.assertEqual(3, p.number_of_presets)
Ejemplo n.º 4
0
    def test_preset_index_can_provide_next_available_slot(self):
        p = PresetIndex()
        p.set_indexes([0, 1, 2, 3, 255])
        self.assertEqual(4, p.next_available_memory_slot)

        p.set_indexes([0, 2, 8, 10, 255])
        self.assertEqual(1, p.next_available_memory_slot)

        p.set_indexes([1, 2, 8, 10, 255])
        self.assertEqual(0, p.next_available_memory_slot)

        p.set_indexes([1, 0, 2, 8, 10, 255])
        self.assertEqual(3, p.next_available_memory_slot)

        # Fill it up entirely
        p.set_indexes(list(range(0, 64)))
        self.assertIsNone(p.next_available_memory_slot)
Ejemplo n.º 5
0
 def test_preset_index_filling_gives_us_64_items(self):
     p = PresetIndex()
     p.set_indexes([0, 255])
     self.assertEqual(1, p.number_of_presets)
     self.assertEqual(64, len(p.indexes))