Skip to content

Commit

Permalink
Fix mod-host: Bug when changing value of a parameter from a plugin. o…
Browse files Browse the repository at this point in the history
…bservable_list: Add method ``.pop()``.
  • Loading branch information
SrMouraSilva committed May 7, 2017
1 parent 25a8336 commit 6197e99
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
7 changes: 4 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Version 0.2.1
Version 0.2.1 -- released 05/07/17
=================================
- Refactor persistence_decoder: Using now design pattern

- Refactor persistence_decoder: Using now design pattern;
- Fix mod-host: Bug when changing value of a parameter from a plugin;
- observable_list: Add method ``.pop()``.

Version 0.2.0 -- released 3/31/17
=================================
Expand Down
4 changes: 2 additions & 2 deletions pluginsmanager/mod_host/protocol_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def param_set(param):
:param Lv2Param param: Parameter that will be updated your value
"""
instance = param.effect
instance = param.effect.instance

return 'param_set {} {} {}'.format(instance, param.symbol, param.value)

Expand All @@ -225,7 +225,7 @@ def param_get(param):
:param Lv2Param param: Parameter that will be get your current value
"""
instance = param.effect
instance = param.effect.instance

return 'param_get {} {}'.format(instance, param.symbol)

Expand Down
1 change: 0 additions & 1 deletion pluginsmanager/util/builder/lv2_json_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pluginsmanager.util.builder.builder import AudioPortBuilder, EffectBuilder


Expand Down
17 changes: 17 additions & 0 deletions pluginsmanager/util/observable_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ def insert(self, index, x):
self._list.insert(index, x)
self.observer(UpdateType.CREATED, x, index)

def pop(self, index=None):
"""
Remove the item at the given position in the list, and return it. If no index is specified,
a.pop() removes and returns the last item in the list.
:param int index: element index that will be removed
:return: item removed
"""
if index is None:
index = len(self._list) - 1

item = self[index]
del self[index]

return item

def __len__(self):
return len(self._list)

Expand Down
40 changes: 40 additions & 0 deletions test/util/observable_list_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,46 @@ def test_remove(self):

lista.observer.assert_called_with(UpdateType.DELETED, '2', 1)

def test_pop_empty_parameter(self):
lista = ObservableList()
a = 'a'
b = 'b'
c = 'c'
d = 'd'

lista.append(a)
lista.append(b)
lista.append(c)
lista.append(d)

lista.observer = MagicMock()

self.assertEqual(d, lista.pop())
self.assertEqual(3, len(lista))

lista.observer.assert_any_call(UpdateType.DELETED, d, len(lista))

def test_pop_with_parameter(self):
lista = ObservableList()
a = 'a'
b = 'b'
c = 'c'
d = 'd'

lista.append(a)
lista.append(b)
lista.append(c)
lista.append(d)

lista.observer = MagicMock()

b_index = 1

self.assertEqual(b, lista.pop(b_index))
self.assertEqual(3, len(lista))

lista.observer.assert_any_call(UpdateType.DELETED, b, b_index)

def test__setitem__(self):
lista = ObservableList()

Expand Down

0 comments on commit 6197e99

Please sign in to comment.