Skip to content

Commit

Permalink
Allow for extra property events
Browse files Browse the repository at this point in the history
  • Loading branch information
nocarryr committed Jun 2, 2021
1 parent 73b6980 commit 91898d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/kv/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ def unbind(self, obj, *events):
obj.unbind(**kwargs)
def empty(self):
return self.queue.empty()
async def assert_empty(self):
await asyncio.sleep(0)
if self.empty():
return True
async with self._lock:
items = []
while not self.empty():
item = await self.queue.get()
self.queue.task_done()
items.append(item)
raise Exception(f'{self} not empty. Queue items: {items}')
async def clear(self):
await asyncio.sleep(0)
async with self._lock:
Expand Down
19 changes: 18 additions & 1 deletion tests/kv/test_kv_presetedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async def do_build(**kwargs_):
await kv_waiter.wait()
kv_waiter.unbind(kivy_app.root, 'active_widget')

await kv_waiter.assert_empty()

edit_widget = kivy_app.root.active_widget.vidhub_edit_widget
preset_widget = edit_widget.preset_label_list

Expand Down Expand Up @@ -76,8 +78,10 @@ async def open_selection_popup(xpt_widget_, selection_type):
preset_widget.add_preset()
await kv_waiter.wait()

preset_item_widget, popup = await open_edit_popup(0)
kv_waiter.unbind(preset_widget, 'list_items')
await kv_waiter.clear()

preset_item_widget, popup = await open_edit_popup(0)

assert popup.preset == preset_item_widget.preset
assert not len(popup.crosspoint_widgets)
Expand All @@ -103,13 +107,17 @@ async def open_selection_popup(xpt_widget_, selection_type):
await kv_waiter.wait()

kv_waiter.unbind(xpt_popup.button_grid, 'selected_buttons')
await kv_waiter.assert_empty()

assert xpt_popup.button_grid.selected_buttons == [1]

kv_waiter.bind(xpt_widget, 'selection_popup')
xpt_popup.dispatch('on_submit')
await kv_waiter.wait()

kv_waiter.unbind(xpt_widget, 'selection_popup')
await kv_waiter.assert_empty()

assert xpt_widget.selection_popup is None
assert xpt_widget.source == 1
assert xpt_widget.source_label == vidhub1.input_labels[1]
Expand All @@ -130,13 +138,17 @@ async def open_selection_popup(xpt_widget_, selection_type):
await kv_waiter.wait()

kv_waiter.unbind(xpt_popup.button_grid, 'selected_buttons')
await kv_waiter.assert_empty()

assert xpt_popup.button_grid.selected_buttons == [1]

kv_waiter.bind(xpt_widget, 'selection_popup')
xpt_popup.dispatch('on_submit')
await kv_waiter.wait()

kv_waiter.unbind(xpt_widget, 'selection_popup')
await kv_waiter.assert_empty()

assert xpt_widget.selection_popup is None
assert xpt_widget.dest == 1
assert xpt_widget.dest_label == vidhub1.output_labels[1]
Expand Down Expand Up @@ -201,6 +213,7 @@ async def open_selection_popup(xpt_widget_, selection_type):
preset = await vidhub1.store_preset()
await kv_waiter.wait()
kv_waiter.unbind(preset_button_grid, 'selected_buttons')
await kv_waiter.clear()

preset_item_widget, popup = await open_edit_popup(preset.index)
print('crosspoint_dict: ', popup.get_crosspoint_dict())
Expand All @@ -218,6 +231,7 @@ async def open_selection_popup(xpt_widget_, selection_type):
popup.crosspoint_widgets[0].dispatch('on_crosspoint_remove', widget=popup.crosspoint_widgets[0])
await kv_waiter.wait()
kv_waiter.unbind(popup, 'crosspoint_widgets')
await kv_waiter.assert_empty()
print('crosspoint_dict: ', popup.get_crosspoint_dict())

assert popup.get_crosspoint_dict() != preset.crosspoints
Expand All @@ -236,6 +250,7 @@ async def open_selection_popup(xpt_widget_, selection_type):
popup.crosspoint_widgets[0].dispatch('on_crosspoint_remove', widget=popup.crosspoint_widgets[0])
await kv_waiter.wait()
kv_waiter.unbind(popup, 'crosspoint_widgets')
await kv_waiter.assert_empty()
print('crosspoint_dict: ', popup.get_crosspoint_dict())

expected_xpts = popup.get_crosspoint_dict()
Expand Down Expand Up @@ -292,12 +307,14 @@ async def open_selection_popup(xpt_widget_, selection_type):
await kv_waiter.wait()

kv_waiter.unbind(xpt_popup.button_grid, 'selected_buttons')
await kv_waiter.assert_empty()
assert xpt_popup.button_grid.selected_buttons == [1]

kv_waiter.bind(xpt_widget, 'selection_popup')
xpt_popup.dispatch('on_submit')
await kv_waiter.wait()
kv_waiter.unbind(xpt_widget, 'selection_popup')
await kv_waiter.assert_empty()

await asyncio.sleep(.1)

Expand Down

0 comments on commit 91898d6

Please sign in to comment.