def test_delete_effect_remove_your_connections(self): pedalboard = Pedalboard('Pedalboard name') builder = Lv2EffectBuilder() reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) reverb.outputs[0].connect(filter.inputs[0]) reverb.outputs[1].connect(filter.inputs[0]) filter.outputs[0].connect(reverb2.inputs[0]) reverb.outputs[0].connect(reverb2.inputs[0]) self.assertEqual(4, len(pedalboard.connections)) pedalboard.observer = MagicMock() fuzz_connections = filter.connections pedalboard.effects.remove(filter) self.assertEqual(1, len(pedalboard.connections)) for connection in fuzz_connections: pedalboard.observer.on_connection_updated.assert_any_call( connection, UpdateType.DELETED, pedalboard=pedalboard)
def test_disconnect(self): pedalboard = Pedalboard('Pedalboard name') builder = OutputTest.builder reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(reverb2) pedalboard.connect(reverb.outputs[0], reverb2.inputs[0]) pedalboard.connect(reverb.outputs[1], reverb2.inputs[0]) self.assertEqual(2, len(pedalboard.connections)) pedalboard.observer = MagicMock() disconnected = pedalboard.connections[-1] pedalboard.disconnect(reverb.outputs[1], reverb2.inputs[0]) self.assertEqual(1, len(pedalboard.connections)) pedalboard.observer.on_connection_updated.assert_called_with(disconnected, UpdateType.DELETED, pedalboard=pedalboard) disconnected = pedalboard.connections[-1] pedalboard.disconnect(reverb.outputs[0], reverb2.inputs[0]) self.assertEqual(0, len(pedalboard.connections)) pedalboard.observer.on_connection_updated.assert_called_with(disconnected, UpdateType.DELETED, pedalboard=pedalboard)
def test_connect(self): pedalboard = Pedalboard('Pedalboard name') pedalboard.observer = MagicMock() builder = MidiOutputTest.builder cctonode = builder.build( 'http://gareus.org/oss/lv2/midifilter#cctonote') cctonode2 = builder.build( 'http://gareus.org/oss/lv2/midifilter#cctonote') pedalboard.append(cctonode) pedalboard.append(cctonode2) self.assertEqual(0, len(pedalboard.connections)) pedalboard.connect(cctonode.midi_outputs[0], cctonode2.midi_inputs[0]) self.assertEqual(1, len(pedalboard.connections)) new_connection = pedalboard.connections[0] pedalboard.observer.on_connection_updated.assert_called_with( new_connection, UpdateType.CREATED, pedalboard=pedalboard) pedalboard.connect(cctonode2.midi_outputs[0], cctonode.midi_inputs[0]) self.assertEqual(2, len(pedalboard.connections)) new_connection = pedalboard.connections[-1] pedalboard.observer.on_connection_updated.assert_called_with( new_connection, UpdateType.CREATED, pedalboard=pedalboard)
def test_data(self): pedalboard = Pedalboard('Bank 1') pedalboard.observer = MagicMock() self.assertEqual({}, pedalboard.data) data = {'my-awesome-component': True} pedalboard.data = data self.assertEqual(data, pedalboard.data)
def test_delete_connection(self): """ Other mode is by output.disconnect(input)""" pedalboard = Pedalboard('Bank 1') connection = MagicMock() pedalboard.connections.append(connection) pedalboard.observer = MagicMock() del pedalboard.connections[0] self.assertEqual(len(pedalboard.connections), 0) pedalboard.observer.on_connection_updated.assert_called_with( connection, UpdateType.DELETED, pedalboard=pedalboard)
def test_update_connection(self): pedalboard = Pedalboard('Pedalboard 1') connection1 = MagicMock() connection2 = MagicMock() pedalboard.connections.append(connection1) pedalboard.observer = MagicMock() pedalboard.connections[0] = connection2 self.assertEqual(pedalboard.connections[0], connection2) pedalboard.observer.on_connection_updated.assert_called_with( connection2, UpdateType.UPDATED, pedalboard=pedalboard)
def test_update_effect(self): pedalboard = Pedalboard('Pedalboard 1') effect1 = MagicMock() effect2 = MagicMock() pedalboard.append(effect1) pedalboard.observer = MagicMock() pedalboard.effects[0] = effect2 self.assertEqual(effect2.pedalboard, pedalboard) self.assertEqual(pedalboard.effects[0], effect2) pedalboard.observer.on_effect_updated.assert_called_with( effect2, UpdateType.UPDATED, index=0, origin=pedalboard)
def test_disconnect_connection_not_created(self): pedalboard = Pedalboard('Pedalboard name') builder = OutputTest.builder reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(reverb2) pedalboard.observer = MagicMock() with self.assertRaises(ValueError): pedalboard.disconnect(reverb.outputs[1], reverb2.inputs[0]) pedalboard.observer.on_connection_updated.assert_not_called()
def test_add_connection_by_connections(self): """ Other mode is by output.connect(input)""" pedalboard = Pedalboard('Pedalboard 1') connection1 = MagicMock() connection2 = MagicMock() pedalboard.observer = MagicMock() pedalboard.connections.append(connection1) self.assertEqual(pedalboard.connections[0], connection1) pedalboard.observer.on_connection_updated.assert_called_with( connection1, UpdateType.CREATED, pedalboard=pedalboard) pedalboard.connections.append(connection2) self.assertEqual(pedalboard.connections[1], connection2) pedalboard.observer.on_connection_updated.assert_called_with( connection2, UpdateType.CREATED, pedalboard=pedalboard)
def test_add_effect_by_effects(self): pedalboard = Pedalboard('Pedalboard 1') effect1 = MagicMock() effect2 = MagicMock() pedalboard.observer = MagicMock() pedalboard.effects.append(effect1) self.assertEqual(effect1.pedalboard, pedalboard) self.assertEqual(pedalboard.effects[0], effect1) pedalboard.observer.on_effect_updated.assert_called_with( effect1, UpdateType.CREATED, index=0, origin=pedalboard) pedalboard.effects.append(effect2) self.assertEqual(effect2.pedalboard, pedalboard) self.assertEqual(pedalboard.effects[1], effect2) pedalboard.observer.on_effect_updated.assert_called_with( effect2, UpdateType.CREATED, index=1, origin=pedalboard)
def test_disconnect_connection_not_created(self): pedalboard = Pedalboard('Pedalboard name') builder = MidiOutputTest.builder cctonode = builder.build( 'http://gareus.org/oss/lv2/midifilter#cctonote') cctonode2 = builder.build( 'http://gareus.org/oss/lv2/midifilter#cctonote') pedalboard.append(cctonode) pedalboard.append(cctonode2) pedalboard.observer = MagicMock() with self.assertRaises(ValueError): pedalboard.disconnect(cctonode.midi_outputs[0], cctonode2.midi_inputs[0]) pedalboard.observer.on_connection_updated.assert_not_called()
def test_delete_effect(self): pedalboard = Pedalboard('Bank 1') effect = MagicMock() effect2 = MagicMock() pedalboard.append(effect) pedalboard.append(effect2) pedalboard.observer = MagicMock() del pedalboard.effects[1] self.assertEqual(effect2.pedalboard, None) self.assertEqual(len(pedalboard.effects), 1) pedalboard.observer.on_effect_updated.assert_called_with( effect2, UpdateType.DELETED, index=1, origin=pedalboard) del pedalboard.effects[0] self.assertEqual(effect.pedalboard, None) self.assertEqual(len(pedalboard.effects), 0) pedalboard.observer.on_effect_updated.assert_called_with( effect, UpdateType.DELETED, index=0, origin=pedalboard)