@@ -14,17 +14,17 @@ def mock_client() -> Mock:
1414
1515
1616@pytest .fixture
17- def command_sender (mock_client : Mock ) -> StreamDeckCommandSender :
17+ def command_sender (mock_client : Mock , plugin_registration_uuid : str ) -> StreamDeckCommandSender :
1818 """Fixture to provide an instance of StreamDeckCommandSender with a mocked client."""
19- return StreamDeckCommandSender (client = mock_client )
19+ return StreamDeckCommandSender (client = mock_client , plugin_registration_uuid = plugin_registration_uuid )
2020
2121
2222@pytest .mark .parametrize (
2323 ("method_name" , "context" , "extra_args" , "expected_event" , "expected_payload" ),
2424 [
2525 (
2626 "get_global_settings" ,
27- "fake_context" ,
27+ None , # get_global_settings uses the command_sender's own plugin_registration_uuid attribute as the context.
2828 {},
2929 "getGlobalSettings" ,
3030 {}
@@ -115,7 +115,7 @@ def command_sender(mock_client: Mock) -> StreamDeckCommandSender:
115115 ),
116116 (
117117 "set_global_settings" ,
118- "fake_context" ,
118+ None , # set_global_settings uses the command_sender's own plugin_registration_uuid attribute as the context.
119119 {"payload" : {"key" : "value" }},
120120 "setGlobalSettings" ,
121121 {"payload" : {"key" : "value" }},
@@ -147,7 +147,7 @@ def test_command_sender_methods(
147147 command_sender : StreamDeckCommandSender ,
148148 mock_client : Mock ,
149149 method_name : str ,
150- context : str ,
150+ context : str | None ,
151151 extra_args : dict ,
152152 expected_event : str ,
153153 expected_payload : dict ,
@@ -157,14 +157,17 @@ def test_command_sender_methods(
157157 assert hasattr (command_sender , method_name )
158158
159159 method = getattr (command_sender , method_name )
160- method (context , ** extra_args )
160+ if context is not None :
161+ method (context , ** extra_args )
162+ else :
163+ method (** extra_args )
161164
162165 # Build the expected data structure to send through the WebSocket
163166 expected_data = {
164- "context" : context ,
167+ "context" : context or command_sender . _plugin_registration_uuid ,
165168 "event" : expected_event ,
166169 ** expected_payload ,
167170 }
168171
169172 # Assert that the client's send_event method was called with the expected data
170- mock_client .send_event .assert_called_once_with (expected_data )
173+ mock_client .send_event .assert_called_once_with (expected_data )
0 commit comments