|
@@ -89,3 +89,24 @@ def test__get_valid_adapter_result(gui: Gui):
|
|
|
res = gui._get_valid_adapter_result(("id", "label"))
|
|
|
assert isinstance(res, tuple)
|
|
|
assert res[0] == "id"
|
|
|
+
|
|
|
+def test_on_action_call(gui:Gui):
|
|
|
+ an_id = "my_id"
|
|
|
+
|
|
|
+ a_non_action_payload = {"a": "b"}
|
|
|
+ def on_action(state, id, payload):
|
|
|
+ assert id == an_id
|
|
|
+ assert payload is a_non_action_payload
|
|
|
+
|
|
|
+ an_action_payload = {"action": "on_an_action"}
|
|
|
+ def on_an_action(state, id, payload):
|
|
|
+ assert id == an_id
|
|
|
+ assert payload is an_action_payload
|
|
|
+
|
|
|
+ # set gui frame
|
|
|
+ gui._set_frame(inspect.currentframe())
|
|
|
+
|
|
|
+ gui.run(run_server=False)
|
|
|
+ with gui.get_flask_app().app_context():
|
|
|
+ gui._Gui__on_action(an_id, a_non_action_payload) # type: ignore[reportAttributeAccessIssue]
|
|
|
+ gui._Gui__on_action(an_id, an_action_payload) # type: ignore[reportAttributeAccessIssue]
|